42#ifndef INCLUDE_NLOHMANN_JSON_HPP_
43#define INCLUDE_NLOHMANN_JSON_HPP_
48#include <initializer_list>
84#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
85 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
86 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 3
87 #warning "Already included a different version of the library!"
92#define NLOHMANN_JSON_VERSION_MAJOR 3
93#define NLOHMANN_JSON_VERSION_MINOR 11
94#define NLOHMANN_JSON_VERSION_PATCH 3
96#ifndef JSON_DIAGNOSTICS
97 #define JSON_DIAGNOSTICS 0
100#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
101 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
105 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
107 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
110#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
111 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
113 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
116#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
117 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
121#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
122#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
123 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
125#define NLOHMANN_JSON_ABI_TAGS \
126 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
127 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
128 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
131#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
132 _v ## major ## _ ## minor ## _ ## patch
133#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
134 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
136#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
137#define NLOHMANN_JSON_NAMESPACE_VERSION
139#define NLOHMANN_JSON_NAMESPACE_VERSION \
140 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
141 NLOHMANN_JSON_VERSION_MINOR, \
142 NLOHMANN_JSON_VERSION_PATCH)
146#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
147#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
148 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
150#ifndef NLOHMANN_JSON_NAMESPACE
151#define NLOHMANN_JSON_NAMESPACE \
152 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
153 NLOHMANN_JSON_ABI_TAGS, \
154 NLOHMANN_JSON_NAMESPACE_VERSION)
157#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
158#define NLOHMANN_JSON_NAMESPACE_BEGIN \
161 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
162 NLOHMANN_JSON_ABI_TAGS, \
163 NLOHMANN_JSON_NAMESPACE_VERSION) \
167#ifndef NLOHMANN_JSON_NAMESPACE_END
168#define NLOHMANN_JSON_NAMESPACE_END \
186#include <forward_list>
191#include <type_traits>
192#include <unordered_map>
255#include <type_traits>
300template<
class Default,
302 template<
class...>
class Op,
310template<
class Default,
template<
class...>
class Op,
class... Args>
317template<
template<
class...>
class Op,
class... Args>
320template<
template<
class...>
class Op,
class... Args>
323template<
template<
class...>
class Op,
class... Args>
326template<
class Default,
template<
class...>
class Op,
class... Args>
329template<
class Default,
template<
class...>
class Op,
class... Args>
332template<
class Expected,
template<
class...>
class Op,
class... Args>
335template<
class To,
template<
class...>
class Op,
class... Args>
337 std::is_convertible<
detected_t<Op, Args...>, To>;
358#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
359#if defined(JSON_HEDLEY_VERSION)
360 #undef JSON_HEDLEY_VERSION
362#define JSON_HEDLEY_VERSION 15
364#if defined(JSON_HEDLEY_STRINGIFY_EX)
365 #undef JSON_HEDLEY_STRINGIFY_EX
367#define JSON_HEDLEY_STRINGIFY_EX(x) #x
369#if defined(JSON_HEDLEY_STRINGIFY)
370 #undef JSON_HEDLEY_STRINGIFY
372#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
374#if defined(JSON_HEDLEY_CONCAT_EX)
375 #undef JSON_HEDLEY_CONCAT_EX
377#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
379#if defined(JSON_HEDLEY_CONCAT)
380 #undef JSON_HEDLEY_CONCAT
382#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
384#if defined(JSON_HEDLEY_CONCAT3_EX)
385 #undef JSON_HEDLEY_CONCAT3_EX
387#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
389#if defined(JSON_HEDLEY_CONCAT3)
390 #undef JSON_HEDLEY_CONCAT3
392#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
394#if defined(JSON_HEDLEY_VERSION_ENCODE)
395 #undef JSON_HEDLEY_VERSION_ENCODE
397#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
399#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
400 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
402#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
404#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
405 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
407#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
409#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
410 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
412#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
414#if defined(JSON_HEDLEY_GNUC_VERSION)
415 #undef JSON_HEDLEY_GNUC_VERSION
417#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
418 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
419#elif defined(__GNUC__)
420 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
423#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
424 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
426#if defined(JSON_HEDLEY_GNUC_VERSION)
427 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
429 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
432#if defined(JSON_HEDLEY_MSVC_VERSION)
433 #undef JSON_HEDLEY_MSVC_VERSION
435#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
436 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
437#elif defined(_MSC_FULL_VER) && !defined(__ICL)
438 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
439#elif defined(_MSC_VER) && !defined(__ICL)
440 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
443#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
444 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
446#if !defined(JSON_HEDLEY_MSVC_VERSION)
447 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
448#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
449 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
450#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
451 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
453 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
456#if defined(JSON_HEDLEY_INTEL_VERSION)
457 #undef JSON_HEDLEY_INTEL_VERSION
459#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
460 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
461#elif defined(__INTEL_COMPILER) && !defined(__ICL)
462 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
465#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
466 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
468#if defined(JSON_HEDLEY_INTEL_VERSION)
469 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
471 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
474#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
475 #undef JSON_HEDLEY_INTEL_CL_VERSION
477#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
478 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
481#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
482 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
484#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
485 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
487 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
490#if defined(JSON_HEDLEY_PGI_VERSION)
491 #undef JSON_HEDLEY_PGI_VERSION
493#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
494 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
497#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
498 #undef JSON_HEDLEY_PGI_VERSION_CHECK
500#if defined(JSON_HEDLEY_PGI_VERSION)
501 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
503 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
506#if defined(JSON_HEDLEY_SUNPRO_VERSION)
507 #undef JSON_HEDLEY_SUNPRO_VERSION
509#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
510 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
511#elif defined(__SUNPRO_C)
512 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
513#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
514 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
515#elif defined(__SUNPRO_CC)
516 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
519#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
520 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
522#if defined(JSON_HEDLEY_SUNPRO_VERSION)
523 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
525 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
528#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
529 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
531#if defined(__EMSCRIPTEN__)
532 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
535#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
536 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
538#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
539 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
541 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
544#if defined(JSON_HEDLEY_ARM_VERSION)
545 #undef JSON_HEDLEY_ARM_VERSION
547#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
548 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
549#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
550 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
553#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
554 #undef JSON_HEDLEY_ARM_VERSION_CHECK
556#if defined(JSON_HEDLEY_ARM_VERSION)
557 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
559 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
562#if defined(JSON_HEDLEY_IBM_VERSION)
563 #undef JSON_HEDLEY_IBM_VERSION
565#if defined(__ibmxl__)
566 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
567#elif defined(__xlC__) && defined(__xlC_ver__)
568 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
569#elif defined(__xlC__)
570 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
573#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
574 #undef JSON_HEDLEY_IBM_VERSION_CHECK
576#if defined(JSON_HEDLEY_IBM_VERSION)
577 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
579 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
582#if defined(JSON_HEDLEY_TI_VERSION)
583 #undef JSON_HEDLEY_TI_VERSION
586 defined(__TI_COMPILER_VERSION__) && \
588 defined(__TMS470__) || defined(__TI_ARM__) || \
589 defined(__MSP430__) || \
590 defined(__TMS320C2000__) \
592#if (__TI_COMPILER_VERSION__ >= 16000000)
593 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
597#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
598 #undef JSON_HEDLEY_TI_VERSION_CHECK
600#if defined(JSON_HEDLEY_TI_VERSION)
601 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
603 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
606#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
607 #undef JSON_HEDLEY_TI_CL2000_VERSION
609#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
610 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
613#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
614 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
616#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
617 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
619 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
622#if defined(JSON_HEDLEY_TI_CL430_VERSION)
623 #undef JSON_HEDLEY_TI_CL430_VERSION
625#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
626 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
629#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
630 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
632#if defined(JSON_HEDLEY_TI_CL430_VERSION)
633 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
635 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
638#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
639 #undef JSON_HEDLEY_TI_ARMCL_VERSION
641#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
642 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
645#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
646 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
648#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
649 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
651 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
654#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
655 #undef JSON_HEDLEY_TI_CL6X_VERSION
657#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
658 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
661#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
662 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
664#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
665 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
667 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
670#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
671 #undef JSON_HEDLEY_TI_CL7X_VERSION
673#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
674 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
677#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
678 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
680#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
681 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
683 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
686#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
687 #undef JSON_HEDLEY_TI_CLPRU_VERSION
689#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
690 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
693#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
694 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
696#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
697 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
699 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
702#if defined(JSON_HEDLEY_CRAY_VERSION)
703 #undef JSON_HEDLEY_CRAY_VERSION
706 #if defined(_RELEASE_PATCHLEVEL)
707 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
709 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
713#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
714 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
716#if defined(JSON_HEDLEY_CRAY_VERSION)
717 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
719 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
722#if defined(JSON_HEDLEY_IAR_VERSION)
723 #undef JSON_HEDLEY_IAR_VERSION
725#if defined(__IAR_SYSTEMS_ICC__)
727 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
729 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
733#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
734 #undef JSON_HEDLEY_IAR_VERSION_CHECK
736#if defined(JSON_HEDLEY_IAR_VERSION)
737 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
739 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
742#if defined(JSON_HEDLEY_TINYC_VERSION)
743 #undef JSON_HEDLEY_TINYC_VERSION
745#if defined(__TINYC__)
746 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
749#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
750 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
752#if defined(JSON_HEDLEY_TINYC_VERSION)
753 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
755 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
758#if defined(JSON_HEDLEY_DMC_VERSION)
759 #undef JSON_HEDLEY_DMC_VERSION
762 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
765#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
766 #undef JSON_HEDLEY_DMC_VERSION_CHECK
768#if defined(JSON_HEDLEY_DMC_VERSION)
769 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
771 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
774#if defined(JSON_HEDLEY_COMPCERT_VERSION)
775 #undef JSON_HEDLEY_COMPCERT_VERSION
777#if defined(__COMPCERT_VERSION__)
778 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
781#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
782 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
784#if defined(JSON_HEDLEY_COMPCERT_VERSION)
785 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
787 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
790#if defined(JSON_HEDLEY_PELLES_VERSION)
791 #undef JSON_HEDLEY_PELLES_VERSION
794 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
797#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
798 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
800#if defined(JSON_HEDLEY_PELLES_VERSION)
801 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
803 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
806#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
807 #undef JSON_HEDLEY_MCST_LCC_VERSION
809#if defined(__LCC__) && defined(__LCC_MINOR__)
810 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
813#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
814 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
816#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
817 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
819 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
822#if defined(JSON_HEDLEY_GCC_VERSION)
823 #undef JSON_HEDLEY_GCC_VERSION
826 defined(JSON_HEDLEY_GNUC_VERSION) && \
827 !defined(__clang__) && \
828 !defined(JSON_HEDLEY_INTEL_VERSION) && \
829 !defined(JSON_HEDLEY_PGI_VERSION) && \
830 !defined(JSON_HEDLEY_ARM_VERSION) && \
831 !defined(JSON_HEDLEY_CRAY_VERSION) && \
832 !defined(JSON_HEDLEY_TI_VERSION) && \
833 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
834 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
835 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
836 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
837 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
838 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
839 !defined(__COMPCERT__) && \
840 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
841 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
844#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
845 #undef JSON_HEDLEY_GCC_VERSION_CHECK
847#if defined(JSON_HEDLEY_GCC_VERSION)
848 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
850 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
853#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
854 #undef JSON_HEDLEY_HAS_ATTRIBUTE
857 defined(__has_attribute) && \
859 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
861# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
863# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
866#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
867 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
869#if defined(__has_attribute)
870 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
872 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
875#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
876 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
878#if defined(__has_attribute)
879 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
881 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
884#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
885 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
888 defined(__has_cpp_attribute) && \
889 defined(__cplusplus) && \
890 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
891 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
893 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
896#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
897 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
899#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
900 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
902 !defined(JSON_HEDLEY_PGI_VERSION) && \
903 !defined(JSON_HEDLEY_IAR_VERSION) && \
904 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
905 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
906 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
908 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
911#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
912 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
914#if defined(__has_cpp_attribute) && defined(__cplusplus)
915 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
917 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
920#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
921 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
923#if defined(__has_cpp_attribute) && defined(__cplusplus)
924 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
926 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
929#if defined(JSON_HEDLEY_HAS_BUILTIN)
930 #undef JSON_HEDLEY_HAS_BUILTIN
932#if defined(__has_builtin)
933 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
935 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
938#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
939 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
941#if defined(__has_builtin)
942 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
944 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
947#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
948 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
950#if defined(__has_builtin)
951 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
953 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
956#if defined(JSON_HEDLEY_HAS_FEATURE)
957 #undef JSON_HEDLEY_HAS_FEATURE
959#if defined(__has_feature)
960 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
962 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
965#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
966 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
968#if defined(__has_feature)
969 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
971 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
974#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
975 #undef JSON_HEDLEY_GCC_HAS_FEATURE
977#if defined(__has_feature)
978 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
980 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
983#if defined(JSON_HEDLEY_HAS_EXTENSION)
984 #undef JSON_HEDLEY_HAS_EXTENSION
986#if defined(__has_extension)
987 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
989 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
992#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
993 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
995#if defined(__has_extension)
996 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
998 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1001#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
1002 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
1004#if defined(__has_extension)
1005 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
1007 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1010#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
1011 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
1013#if defined(__has_declspec_attribute)
1014 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
1016 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
1019#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
1020 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
1022#if defined(__has_declspec_attribute)
1023 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1025 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1028#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1029 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1031#if defined(__has_declspec_attribute)
1032 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1034 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1037#if defined(JSON_HEDLEY_HAS_WARNING)
1038 #undef JSON_HEDLEY_HAS_WARNING
1040#if defined(__has_warning)
1041 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1043 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1046#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1047 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1049#if defined(__has_warning)
1050 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1052 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1055#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1056 #undef JSON_HEDLEY_GCC_HAS_WARNING
1058#if defined(__has_warning)
1059 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1061 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1065 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1066 defined(__clang__) || \
1067 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1068 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1069 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1070 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1071 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1072 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1073 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1074 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1075 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1076 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1077 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1078 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1079 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1080 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1081 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1082 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1083 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1084#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1085 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1087 #define JSON_HEDLEY_PRAGMA(value)
1090#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1091 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1093#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1094 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1096#if defined(__clang__)
1097 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1098 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1099#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1100 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1101 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1102#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1103 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1104 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1106 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1107 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1109 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1110#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1111 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1112 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1114 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1115 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1116 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1117 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1118 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1119 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1120 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1121 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1122#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1123 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1124 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1126 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1127 #define JSON_HEDLEY_DIAGNOSTIC_POP
1132#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1133 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1135#if defined(__cplusplus)
1136# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1137# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1138# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1139# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1140 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1141 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1142 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1143 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1145 JSON_HEDLEY_DIAGNOSTIC_POP
1147# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1148 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1149 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1150 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1152 JSON_HEDLEY_DIAGNOSTIC_POP
1155# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1156 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1157 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1159 JSON_HEDLEY_DIAGNOSTIC_POP
1163#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1164 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1167#if defined(JSON_HEDLEY_CONST_CAST)
1168 #undef JSON_HEDLEY_CONST_CAST
1170#if defined(__cplusplus)
1171# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1173 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1174 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1175 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1176# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1177 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1178 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1180 JSON_HEDLEY_DIAGNOSTIC_POP \
1183# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1186#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1187 #undef JSON_HEDLEY_REINTERPRET_CAST
1189#if defined(__cplusplus)
1190 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1192 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1195#if defined(JSON_HEDLEY_STATIC_CAST)
1196 #undef JSON_HEDLEY_STATIC_CAST
1198#if defined(__cplusplus)
1199 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1201 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1204#if defined(JSON_HEDLEY_CPP_CAST)
1205 #undef JSON_HEDLEY_CPP_CAST
1207#if defined(__cplusplus)
1208# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1209# define JSON_HEDLEY_CPP_CAST(T, expr) \
1210 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1211 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1213 JSON_HEDLEY_DIAGNOSTIC_POP
1214# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1215# define JSON_HEDLEY_CPP_CAST(T, expr) \
1216 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1217 _Pragma("diag_suppress=Pe137") \
1218 JSON_HEDLEY_DIAGNOSTIC_POP
1220# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1223# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1226#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1227 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1229#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1230 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1231#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1232 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1233#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1234 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1235#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1236 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1237#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1238 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1239#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1240 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1241#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1242 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1243#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1244 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1246 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1247 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1248 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1249 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1250 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1251 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1252 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1253 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1254 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1255 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1256 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1257 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1258#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1259 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1260#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1261 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1262#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1263 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1264#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1265 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1267 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1270#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1271 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1273#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1275#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1276 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1277#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1278 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1279#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1280 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1281#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1282 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1283#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1284 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1286 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1287 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1288 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1289 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1290 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1291#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1292 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1293#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1294 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1295#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1296 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1298 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1301#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1302 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1304#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1305 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1306#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1307 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1308#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1309 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1310#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1311 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1312#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1314#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1316#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1318#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1321 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1322 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1323 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1324 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1325#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1327#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1333#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1334 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1336#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1337 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1338#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1339 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1340#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1341 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1343 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1346#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1347 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1349#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1350 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1351#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1352 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1353#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1354 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1355#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1356 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1358 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1361#if defined(JSON_HEDLEY_DEPRECATED)
1362 #undef JSON_HEDLEY_DEPRECATED
1364#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1365 #undef JSON_HEDLEY_DEPRECATED_FOR
1368 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1369 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1370 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1371 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1373 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1374 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1375 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1376 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1377 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1378 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1379 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1380 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1381 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1382 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1383 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1384 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1385 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1386 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1387#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1388 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1389 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1391 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1392 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1393 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1394 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1395 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1396 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1397 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1398 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1399 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1400 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1401 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1402 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1403 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1404 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1405 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1406 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1407 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1408 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1410 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1411 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1412 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1413 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1414 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1415#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1416 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1417 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1419 #define JSON_HEDLEY_DEPRECATED(since)
1420 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1423#if defined(JSON_HEDLEY_UNAVAILABLE)
1424 #undef JSON_HEDLEY_UNAVAILABLE
1427 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1428 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1429 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1430 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1431 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1433 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1436#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1437 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1439#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1440 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1443 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1444 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1445 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1446 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1447 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1448 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1449 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1450 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1451 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1452 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1453 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1454 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1455 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1456 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1457 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1458 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1459 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1460 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1461 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1462#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1463 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1464 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1465#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1466 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1467 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1468#elif defined(_Check_return_)
1469 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1470 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1472 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1473 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1476#if defined(JSON_HEDLEY_SENTINEL)
1477 #undef JSON_HEDLEY_SENTINEL
1480 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1481 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1482 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1483 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1484 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1485 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1487 #define JSON_HEDLEY_SENTINEL(position)
1490#if defined(JSON_HEDLEY_NO_RETURN)
1491 #undef JSON_HEDLEY_NO_RETURN
1493#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1494 #define JSON_HEDLEY_NO_RETURN __noreturn
1496 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1497 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1498 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1499#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1500 #define JSON_HEDLEY_NO_RETURN _Noreturn
1501#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1502 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1504 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1505 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1506 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1507 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1508 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1509 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1510 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1511 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1512 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1513 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1514 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1515 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1516 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1517 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1518 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1519 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1520 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1521 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1522#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1523 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1525 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1526 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1527 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1528#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1529 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1530#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1531 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1532#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1533 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1535 #define JSON_HEDLEY_NO_RETURN
1538#if defined(JSON_HEDLEY_NO_ESCAPE)
1539 #undef JSON_HEDLEY_NO_ESCAPE
1541#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1542 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1544 #define JSON_HEDLEY_NO_ESCAPE
1547#if defined(JSON_HEDLEY_UNREACHABLE)
1548 #undef JSON_HEDLEY_UNREACHABLE
1550#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1551 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1553#if defined(JSON_HEDLEY_ASSUME)
1554 #undef JSON_HEDLEY_ASSUME
1557 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1558 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1559 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1560 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1561#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1562 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1564 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1565 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1566 #if defined(__cplusplus)
1567 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1569 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1573 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1574 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1575 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1576 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1577 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1578 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1579 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1580 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1581#elif defined(JSON_HEDLEY_ASSUME)
1582 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1584#if !defined(JSON_HEDLEY_ASSUME)
1585 #if defined(JSON_HEDLEY_UNREACHABLE)
1586 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1588 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1591#if defined(JSON_HEDLEY_UNREACHABLE)
1593 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1594 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1595 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1597 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1600 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1602#if !defined(JSON_HEDLEY_UNREACHABLE)
1603 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1607#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1608 #pragma clang diagnostic ignored "-Wpedantic"
1610#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1611 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1613#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1614 #if defined(__clang__)
1615 #pragma clang diagnostic ignored "-Wvariadic-macros"
1616 #elif defined(JSON_HEDLEY_GCC_VERSION)
1617 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1620#if defined(JSON_HEDLEY_NON_NULL)
1621 #undef JSON_HEDLEY_NON_NULL
1624 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1625 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1626 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1627 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1628 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1630 #define JSON_HEDLEY_NON_NULL(...)
1634#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1635 #undef JSON_HEDLEY_PRINTF_FORMAT
1637#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1638 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1639#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1640 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1642 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1643 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1644 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1645 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1646 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1647 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1648 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1649 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1650 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1651 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1652 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1653 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1654 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1655 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1656 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1657 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1658 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1659 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1660#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1661 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1663 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1666#if defined(JSON_HEDLEY_CONSTEXPR)
1667 #undef JSON_HEDLEY_CONSTEXPR
1669#if defined(__cplusplus)
1670 #if __cplusplus >= 201103L
1671 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1674#if !defined(JSON_HEDLEY_CONSTEXPR)
1675 #define JSON_HEDLEY_CONSTEXPR
1678#if defined(JSON_HEDLEY_PREDICT)
1679 #undef JSON_HEDLEY_PREDICT
1681#if defined(JSON_HEDLEY_LIKELY)
1682 #undef JSON_HEDLEY_LIKELY
1684#if defined(JSON_HEDLEY_UNLIKELY)
1685 #undef JSON_HEDLEY_UNLIKELY
1687#if defined(JSON_HEDLEY_UNPREDICTABLE)
1688 #undef JSON_HEDLEY_UNPREDICTABLE
1690#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1691 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1694 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1695 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1696 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1697# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1698# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1699# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1700# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1701# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1703 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1704 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1705 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1706 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1707 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1708 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1709 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1710 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1711 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1712 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1713 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1714 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1715 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1716 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1717 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1718 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1719# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1720 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1721# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1723 double hedley_probability_ = (probability); \
1724 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1726# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1728 double hedley_probability_ = (probability); \
1729 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1731# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1732# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1734# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1735# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1736# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1737# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1738# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1740#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1741 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1744#if defined(JSON_HEDLEY_MALLOC)
1745 #undef JSON_HEDLEY_MALLOC
1748 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1749 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1750 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1751 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1752 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1753 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1754 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1755 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1756 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1757 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1758 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1759 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1760 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1761 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1762 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1763 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1764 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1765 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1766 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1767#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1768 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1770 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1771 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1772 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1774 #define JSON_HEDLEY_MALLOC
1777#if defined(JSON_HEDLEY_PURE)
1778 #undef JSON_HEDLEY_PURE
1781 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1782 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1783 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1784 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1785 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1786 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1787 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1788 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1789 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1790 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1791 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1792 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1793 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1794 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1795 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1796 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1797 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1798 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1799 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1800# define JSON_HEDLEY_PURE __attribute__((__pure__))
1801#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1802# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1803#elif defined(__cplusplus) && \
1805 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1806 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1807 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1809# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1811# define JSON_HEDLEY_PURE
1814#if defined(JSON_HEDLEY_CONST)
1815 #undef JSON_HEDLEY_CONST
1818 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1819 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1820 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1821 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1822 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1823 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1824 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1825 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1826 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1827 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1828 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1829 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1830 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1831 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1832 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1833 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1834 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1835 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1836 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1837 #define JSON_HEDLEY_CONST __attribute__((__const__))
1839 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1840 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1842 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1845#if defined(JSON_HEDLEY_RESTRICT)
1846 #undef JSON_HEDLEY_RESTRICT
1848#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1849 #define JSON_HEDLEY_RESTRICT restrict
1851 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1852 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1853 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1854 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1855 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1856 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1857 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1858 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1859 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1860 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1861 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1862 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1863 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1864 defined(__clang__) || \
1865 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1866 #define JSON_HEDLEY_RESTRICT __restrict
1867#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1868 #define JSON_HEDLEY_RESTRICT _Restrict
1870 #define JSON_HEDLEY_RESTRICT
1873#if defined(JSON_HEDLEY_INLINE)
1874 #undef JSON_HEDLEY_INLINE
1877 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1878 (defined(__cplusplus) && (__cplusplus >= 199711L))
1879 #define JSON_HEDLEY_INLINE inline
1881 defined(JSON_HEDLEY_GCC_VERSION) || \
1882 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1883 #define JSON_HEDLEY_INLINE __inline__
1885 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1886 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1887 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1888 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1889 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1890 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1891 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1892 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1893 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1894 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1895 #define JSON_HEDLEY_INLINE __inline
1897 #define JSON_HEDLEY_INLINE
1900#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1901 #undef JSON_HEDLEY_ALWAYS_INLINE
1904 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1905 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1906 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1907 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1908 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1909 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1910 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1911 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1912 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1913 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1914 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1915 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1916 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1917 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1918 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1919 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1920 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1921 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1922 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1923# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1925 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1926 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1927# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1928#elif defined(__cplusplus) && \
1930 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1931 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1932 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1933 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1934 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1935 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1937# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1938#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1939# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1941# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1944#if defined(JSON_HEDLEY_NEVER_INLINE)
1945 #undef JSON_HEDLEY_NEVER_INLINE
1948 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1949 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1950 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1951 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1952 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1953 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1954 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1955 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1956 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1957 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1958 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1959 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1960 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1961 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1962 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1963 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1964 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1965 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1966 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1967 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1969 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1970 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1971 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1972#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1973 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1974#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1975 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1976#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1977 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1978#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1979 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1980#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1981 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1983 #define JSON_HEDLEY_NEVER_INLINE
1986#if defined(JSON_HEDLEY_PRIVATE)
1987 #undef JSON_HEDLEY_PRIVATE
1989#if defined(JSON_HEDLEY_PUBLIC)
1990 #undef JSON_HEDLEY_PUBLIC
1992#if defined(JSON_HEDLEY_IMPORT)
1993 #undef JSON_HEDLEY_IMPORT
1995#if defined(_WIN32) || defined(__CYGWIN__)
1996# define JSON_HEDLEY_PRIVATE
1997# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1998# define JSON_HEDLEY_IMPORT __declspec(dllimport)
2001 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
2002 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2003 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
2004 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2005 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2006 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2008 defined(__TI_EABI__) && \
2010 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
2011 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
2014 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2015# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
2016# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
2018# define JSON_HEDLEY_PRIVATE
2019# define JSON_HEDLEY_PUBLIC
2021# define JSON_HEDLEY_IMPORT extern
2024#if defined(JSON_HEDLEY_NO_THROW)
2025 #undef JSON_HEDLEY_NO_THROW
2028 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2029 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2030 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2031 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2032 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2034 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2035 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2036 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2037 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2039 #define JSON_HEDLEY_NO_THROW
2042#if defined(JSON_HEDLEY_FALL_THROUGH)
2043 #undef JSON_HEDLEY_FALL_THROUGH
2046 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2047 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2048 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2049 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2050#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2051 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2052#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2053 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2054#elif defined(__fallthrough)
2055 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2057 #define JSON_HEDLEY_FALL_THROUGH
2060#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2061 #undef JSON_HEDLEY_RETURNS_NON_NULL
2064 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2065 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2066 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2067 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2068#elif defined(_Ret_notnull_)
2069 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2071 #define JSON_HEDLEY_RETURNS_NON_NULL
2074#if defined(JSON_HEDLEY_ARRAY_PARAM)
2075 #undef JSON_HEDLEY_ARRAY_PARAM
2078 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2079 !defined(__STDC_NO_VLA__) && \
2080 !defined(__cplusplus) && \
2081 !defined(JSON_HEDLEY_PGI_VERSION) && \
2082 !defined(JSON_HEDLEY_TINYC_VERSION)
2083 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2085 #define JSON_HEDLEY_ARRAY_PARAM(name)
2088#if defined(JSON_HEDLEY_IS_CONSTANT)
2089 #undef JSON_HEDLEY_IS_CONSTANT
2091#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2092 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2096#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2097 #undef JSON_HEDLEY_IS_CONSTEXPR_
2100 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2101 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2102 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2103 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2104 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2105 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2106 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2107 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2108 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2109 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2110 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2112#if !defined(__cplusplus)
2114 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2115 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2116 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2117 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2118 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2119 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2120 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2121#if defined(__INTPTR_TYPE__)
2122 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2125 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2129 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2130 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2131 !defined(JSON_HEDLEY_PGI_VERSION) && \
2132 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2133 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2134 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2135 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2136 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2137 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2138#if defined(__INTPTR_TYPE__)
2139 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2142 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2145 defined(JSON_HEDLEY_GCC_VERSION) || \
2146 defined(JSON_HEDLEY_INTEL_VERSION) || \
2147 defined(JSON_HEDLEY_TINYC_VERSION) || \
2148 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2149 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2150 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2151 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2152 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2153 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2155# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2159 ((void*) ((expr) * 0L) ) : \
2160((struct { char v[sizeof(void) * 2]; } *) 1) \
2166#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2167 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2168 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2170 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2172 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2173 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2175 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2178#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2179 #undef JSON_HEDLEY_BEGIN_C_DECLS
2181#if defined(JSON_HEDLEY_END_C_DECLS)
2182 #undef JSON_HEDLEY_END_C_DECLS
2184#if defined(JSON_HEDLEY_C_DECL)
2185 #undef JSON_HEDLEY_C_DECL
2187#if defined(__cplusplus)
2188 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2189 #define JSON_HEDLEY_END_C_DECLS }
2190 #define JSON_HEDLEY_C_DECL extern "C"
2192 #define JSON_HEDLEY_BEGIN_C_DECLS
2193 #define JSON_HEDLEY_END_C_DECLS
2194 #define JSON_HEDLEY_C_DECL
2197#if defined(JSON_HEDLEY_STATIC_ASSERT)
2198 #undef JSON_HEDLEY_STATIC_ASSERT
2201 !defined(__cplusplus) && ( \
2202 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2203 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2204 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2205 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2206 defined(_Static_assert) \
2208# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2210 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2211 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2212 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2213# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2215# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2218#if defined(JSON_HEDLEY_NULL)
2219 #undef JSON_HEDLEY_NULL
2221#if defined(__cplusplus)
2222 #if __cplusplus >= 201103L
2223 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2225 #define JSON_HEDLEY_NULL NULL
2227 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2230 #define JSON_HEDLEY_NULL NULL
2232 #define JSON_HEDLEY_NULL ((void*) 0)
2235#if defined(JSON_HEDLEY_MESSAGE)
2236 #undef JSON_HEDLEY_MESSAGE
2238#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2239# define JSON_HEDLEY_MESSAGE(msg) \
2240 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2241 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2242 JSON_HEDLEY_PRAGMA(message msg) \
2243 JSON_HEDLEY_DIAGNOSTIC_POP
2245 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2246 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2247# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2248#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2249# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2250#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2251# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2252#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2253# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2255# define JSON_HEDLEY_MESSAGE(msg)
2258#if defined(JSON_HEDLEY_WARNING)
2259 #undef JSON_HEDLEY_WARNING
2261#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2262# define JSON_HEDLEY_WARNING(msg) \
2263 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2264 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2265 JSON_HEDLEY_PRAGMA(clang warning msg) \
2266 JSON_HEDLEY_DIAGNOSTIC_POP
2268 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2269 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2270 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2271# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2273 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2274 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2275# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2277# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2280#if defined(JSON_HEDLEY_REQUIRE)
2281 #undef JSON_HEDLEY_REQUIRE
2283#if defined(JSON_HEDLEY_REQUIRE_MSG)
2284 #undef JSON_HEDLEY_REQUIRE_MSG
2286#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2287# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2288# define JSON_HEDLEY_REQUIRE(expr) \
2289 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2290 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2291 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2292 JSON_HEDLEY_DIAGNOSTIC_POP
2293# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2294 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2295 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2296 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2297 JSON_HEDLEY_DIAGNOSTIC_POP
2299# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2300# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2303# define JSON_HEDLEY_REQUIRE(expr)
2304# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2307#if defined(JSON_HEDLEY_FLAGS)
2308 #undef JSON_HEDLEY_FLAGS
2310#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2311 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2313 #define JSON_HEDLEY_FLAGS
2316#if defined(JSON_HEDLEY_FLAGS_CAST)
2317 #undef JSON_HEDLEY_FLAGS_CAST
2319#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2320# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2321 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2322 _Pragma("warning(disable:188)") \
2324 JSON_HEDLEY_DIAGNOSTIC_POP \
2327# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2330#if defined(JSON_HEDLEY_EMPTY_BASES)
2331 #undef JSON_HEDLEY_EMPTY_BASES
2334 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2335 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2336 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2338 #define JSON_HEDLEY_EMPTY_BASES
2343#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2344 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2346#if defined(__clang__)
2347 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2349 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2352#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2353 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2355#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2357#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2358 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2360#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2362#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2363 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2365#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2367#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2368 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2370#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2372#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2373 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2375#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2377#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2378 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2380#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2382#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2383 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2385#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2397#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2398 #if defined(__clang__)
2399 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2400 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2402 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2403 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2404 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2411#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2412 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2413 #define JSON_HAS_CPP_20
2414 #define JSON_HAS_CPP_17
2415 #define JSON_HAS_CPP_14
2416 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2417 #define JSON_HAS_CPP_17
2418 #define JSON_HAS_CPP_14
2419 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2420 #define JSON_HAS_CPP_14
2423 #define JSON_HAS_CPP_11
2427 #if __has_include(<version>)
2432#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2433 #ifdef JSON_HAS_CPP_17
2434 #if defined(__cpp_lib_filesystem)
2435 #define JSON_HAS_FILESYSTEM 1
2436 #elif defined(__cpp_lib_experimental_filesystem)
2437 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2438 #elif !defined(__has_include)
2439 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2440 #elif __has_include(<filesystem>)
2441 #define JSON_HAS_FILESYSTEM 1
2442 #elif __has_include(<experimental/filesystem>)
2443 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2447 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2448 #undef JSON_HAS_FILESYSTEM
2449 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2453 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2454 #undef JSON_HAS_FILESYSTEM
2455 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2459 #if defined(__clang_major__) && __clang_major__ < 7
2460 #undef JSON_HAS_FILESYSTEM
2461 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2465 #if defined(_MSC_VER) && _MSC_VER < 1914
2466 #undef JSON_HAS_FILESYSTEM
2467 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2471 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2472 #undef JSON_HAS_FILESYSTEM
2473 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2477 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2478 #undef JSON_HAS_FILESYSTEM
2479 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2484#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2485 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2488#ifndef JSON_HAS_FILESYSTEM
2489 #define JSON_HAS_FILESYSTEM 0
2492#ifndef JSON_HAS_THREE_WAY_COMPARISON
2493 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2494 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2495 #define JSON_HAS_THREE_WAY_COMPARISON 1
2497 #define JSON_HAS_THREE_WAY_COMPARISON 0
2501#ifndef JSON_HAS_RANGES
2503 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2504 #define JSON_HAS_RANGES 0
2505 #elif defined(__cpp_lib_ranges)
2506 #define JSON_HAS_RANGES 1
2508 #define JSON_HAS_RANGES 0
2512#ifndef JSON_HAS_STATIC_RTTI
2513 #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0
2514 #define JSON_HAS_STATIC_RTTI 1
2516 #define JSON_HAS_STATIC_RTTI 0
2520#ifdef JSON_HAS_CPP_17
2521 #define JSON_INLINE_VARIABLE inline
2523 #define JSON_INLINE_VARIABLE
2526#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2527 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2529 #define JSON_NO_UNIQUE_ADDRESS
2533#if defined(__clang__)
2534 #pragma clang diagnostic push
2535 #pragma clang diagnostic ignored "-Wdocumentation"
2536 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2540#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2541 #define JSON_THROW(exception) throw exception
2542 #define JSON_TRY try
2543 #define JSON_CATCH(exception) catch(exception)
2544 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2547 #define JSON_THROW(exception) std::abort()
2548 #define JSON_TRY if(true)
2549 #define JSON_CATCH(exception) if(false)
2550 #define JSON_INTERNAL_CATCH(exception) if(false)
2554#if defined(JSON_THROW_USER)
2556 #define JSON_THROW JSON_THROW_USER
2558#if defined(JSON_TRY_USER)
2560 #define JSON_TRY JSON_TRY_USER
2562#if defined(JSON_CATCH_USER)
2564 #define JSON_CATCH JSON_CATCH_USER
2565 #undef JSON_INTERNAL_CATCH
2566 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2568#if defined(JSON_INTERNAL_CATCH_USER)
2569 #undef JSON_INTERNAL_CATCH
2570 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2574#if !defined(JSON_ASSERT)
2576 #define JSON_ASSERT(x) assert(x)
2580#if defined(JSON_TESTS_PRIVATE)
2581 #define JSON_PRIVATE_UNLESS_TESTED public
2583 #define JSON_PRIVATE_UNLESS_TESTED private
2591#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2592 template<typename BasicJsonType> \
2593 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2595 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2596 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2597 auto it = std::find_if(std::begin(m), std::end(m), \
2598 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2600 return ej_pair.first == e; \
2602 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2604 template<typename BasicJsonType> \
2605 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2607 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2608 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2609 auto it = std::find_if(std::begin(m), std::end(m), \
2610 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2612 return ej_pair.second == j; \
2614 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2620#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2621 template<template<typename, typename, typename...> class ObjectType, \
2622 template<typename, typename...> class ArrayType, \
2623 class StringType, class BooleanType, class NumberIntegerType, \
2624 class NumberUnsignedType, class NumberFloatType, \
2625 template<typename> class AllocatorType, \
2626 template<typename, typename = void> class JSONSerializer, \
2628 class CustomBaseClass>
2630#define NLOHMANN_BASIC_JSON_TPL \
2631 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2632 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2633 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2637#define NLOHMANN_JSON_EXPAND( x ) x
2638#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2639#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2640 NLOHMANN_JSON_PASTE64, \
2641 NLOHMANN_JSON_PASTE63, \
2642 NLOHMANN_JSON_PASTE62, \
2643 NLOHMANN_JSON_PASTE61, \
2644 NLOHMANN_JSON_PASTE60, \
2645 NLOHMANN_JSON_PASTE59, \
2646 NLOHMANN_JSON_PASTE58, \
2647 NLOHMANN_JSON_PASTE57, \
2648 NLOHMANN_JSON_PASTE56, \
2649 NLOHMANN_JSON_PASTE55, \
2650 NLOHMANN_JSON_PASTE54, \
2651 NLOHMANN_JSON_PASTE53, \
2652 NLOHMANN_JSON_PASTE52, \
2653 NLOHMANN_JSON_PASTE51, \
2654 NLOHMANN_JSON_PASTE50, \
2655 NLOHMANN_JSON_PASTE49, \
2656 NLOHMANN_JSON_PASTE48, \
2657 NLOHMANN_JSON_PASTE47, \
2658 NLOHMANN_JSON_PASTE46, \
2659 NLOHMANN_JSON_PASTE45, \
2660 NLOHMANN_JSON_PASTE44, \
2661 NLOHMANN_JSON_PASTE43, \
2662 NLOHMANN_JSON_PASTE42, \
2663 NLOHMANN_JSON_PASTE41, \
2664 NLOHMANN_JSON_PASTE40, \
2665 NLOHMANN_JSON_PASTE39, \
2666 NLOHMANN_JSON_PASTE38, \
2667 NLOHMANN_JSON_PASTE37, \
2668 NLOHMANN_JSON_PASTE36, \
2669 NLOHMANN_JSON_PASTE35, \
2670 NLOHMANN_JSON_PASTE34, \
2671 NLOHMANN_JSON_PASTE33, \
2672 NLOHMANN_JSON_PASTE32, \
2673 NLOHMANN_JSON_PASTE31, \
2674 NLOHMANN_JSON_PASTE30, \
2675 NLOHMANN_JSON_PASTE29, \
2676 NLOHMANN_JSON_PASTE28, \
2677 NLOHMANN_JSON_PASTE27, \
2678 NLOHMANN_JSON_PASTE26, \
2679 NLOHMANN_JSON_PASTE25, \
2680 NLOHMANN_JSON_PASTE24, \
2681 NLOHMANN_JSON_PASTE23, \
2682 NLOHMANN_JSON_PASTE22, \
2683 NLOHMANN_JSON_PASTE21, \
2684 NLOHMANN_JSON_PASTE20, \
2685 NLOHMANN_JSON_PASTE19, \
2686 NLOHMANN_JSON_PASTE18, \
2687 NLOHMANN_JSON_PASTE17, \
2688 NLOHMANN_JSON_PASTE16, \
2689 NLOHMANN_JSON_PASTE15, \
2690 NLOHMANN_JSON_PASTE14, \
2691 NLOHMANN_JSON_PASTE13, \
2692 NLOHMANN_JSON_PASTE12, \
2693 NLOHMANN_JSON_PASTE11, \
2694 NLOHMANN_JSON_PASTE10, \
2695 NLOHMANN_JSON_PASTE9, \
2696 NLOHMANN_JSON_PASTE8, \
2697 NLOHMANN_JSON_PASTE7, \
2698 NLOHMANN_JSON_PASTE6, \
2699 NLOHMANN_JSON_PASTE5, \
2700 NLOHMANN_JSON_PASTE4, \
2701 NLOHMANN_JSON_PASTE3, \
2702 NLOHMANN_JSON_PASTE2, \
2703 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2704#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2705#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2706#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2707#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2708#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2709#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2710#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2711#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2712#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2713#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2714#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2715#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2716#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2717#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2718#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2719#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2720#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2721#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2722#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2723#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2724#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2725#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2726#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2727#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2728#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2729#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2730#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2731#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2732#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2733#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2734#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2735#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2736#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2737#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2738#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2739#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2740#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2741#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2742#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2743#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2744#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2745#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2746#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2747#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2748#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2749#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2750#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2751#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2752#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2753#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2754#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2755#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2756#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2757#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2758#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2759#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2760#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2761#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2762#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2763#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2764#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2765#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2766#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2768#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2769#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2770#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2777#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2778 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2779 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2781#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2782 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2783 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2785#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2786 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2793#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2794 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2795 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2797#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \
2798 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) }
2800#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2801 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2802 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2810#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2811 namespace detail { \
2812 using std::std_name; \
2814 template<typename... T> \
2815 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2818 namespace detail2 { \
2819 struct std_name##_tag \
2823 template<typename... T> \
2824 std_name##_tag std_name(T&&...); \
2826 template<typename... T> \
2827 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2829 template<typename... T> \
2830 struct would_call_std_##std_name \
2832 static constexpr auto const value = ::nlohmann::detail:: \
2833 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2837 template<typename... T> \
2838 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2842#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2843 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2846#if JSON_USE_IMPLICIT_CONVERSIONS
2847 #define JSON_EXPLICIT
2849 #define JSON_EXPLICIT explicit
2852#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2853 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2856#ifndef JSON_USE_GLOBAL_UDLS
2857 #define JSON_USE_GLOBAL_UDLS 1
2860#if JSON_HAS_THREE_WAY_COMPARISON
2923#if JSON_HAS_THREE_WAY_COMPARISON
2924 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2929 static constexpr std::array<std::uint8_t, 9> order = {{
2936 const auto l_index =
static_cast<std::size_t
>(lhs);
2937 const auto r_index =
static_cast<std::size_t
>(rhs);
2938#if JSON_HAS_THREE_WAY_COMPARISON
2939 if (l_index < order.size() && r_index < order.size())
2941 return order[l_index] <=> order[r_index];
2943 return std::partial_ordering::unordered;
2945 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2953#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2956 return std::is_lt(lhs <=> rhs);
2994template<
typename StringType>
2996 const StringType& t)
2999 for (
auto pos = s.find(f);
3000 pos != StringType::npos;
3001 s.replace(pos, f.size(), t),
3002 pos = s.find(f, pos + t.size()))
3013template<
typename StringType>
3028template<
typename StringType>
3029static void unescape(StringType& s)
3069 constexpr operator size_t()
const
3094#include <type_traits>
3105using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3107#ifdef JSON_HAS_CPP_14
3110using std::enable_if_t;
3111using std::index_sequence;
3112using std::make_index_sequence;
3113using std::index_sequence_for;
3118template<
bool B,
typename T =
void>
3145template <
typename T, T... Ints>
3149 static constexpr std::size_t
size() noexcept
3151 return sizeof...(Ints);
3160template <
size_t... Ints>
3163namespace utility_internal
3166template <
typename Seq,
size_t SeqSize,
size_t Rem>
3170template <
typename T, T... Ints,
size_t SeqSize>
3176template <
typename T, T... Ints,
size_t SeqSize>
3184template <
typename T,
size_t N>
3191template <
typename T>
3206template <
typename T, T N>
3222template <
typename... Ts>
3240#ifndef JSON_HAS_CPP_17
3241 template<
typename T>
3245template<
typename T,
typename... Args>
3246inline constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3248 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3266#include <type_traits>
3295template<
typename It,
typename =
void>
3298template<
typename It>
3302 typename It::reference, typename It::iterator_category >>
3313template<
typename T,
typename =
void>
3392#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3393 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3418 template<
typename T =
void,
typename SFINAE =
void>
3423 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3425 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3426 class StringType = std::string,
class BooleanType = bool,
3427 class NumberIntegerType = std::int64_t,
3428 class NumberUnsignedType = std::uint64_t,
3429 class NumberFloatType = double,
3430 template<
typename U>
class AllocatorType = std::allocator,
3431 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3433 class BinaryType = std::vector<std::uint8_t>,
3434 class CustomBaseClass =
void>
3439 template<
typename RefStringType>
3450 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3495template<
typename BasicJsonContext>
3497 std::integral_constant < bool,
3498 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3499 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3540template<
typename T,
typename... Args>
3543template<
typename T,
typename... Args>
3546template<
typename T,
typename U>
3550template<
typename BasicJsonType,
typename T,
typename =
void>
3557template <
typename BasicJsonType,
typename T>
3563template<
typename BasicJsonType,
typename T>
3566 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3570 const BasicJsonType&, T&>
::value;
3575template<
typename BasicJsonType,
typename T,
typename =
void>
3578template<
typename BasicJsonType,
typename T>
3581 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3590template<
typename BasicJsonType,
typename T,
typename =
void>
3593template<
typename BasicJsonType,
typename T>
3596 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3607struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3610template<
typename BasicJsonType>
3615 using type =
typename std::conditional < has_key_compare<object_t>::value,
3619template<
typename BasicJsonType>
3686template<
class B,
class... Bn>
3688: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3691template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3696template <
typename T>
3699template <
typename T1,
typename T2>
3701 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3703template <
typename T1,
typename T2>
3705 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3707template <
typename... Ts>
3709 :
conjunction<is_default_constructible<Ts>...> {};
3711template <
typename... Ts>
3713 :
conjunction<is_default_constructible<Ts>...> {};
3715template <
typename T,
typename... Args>
3718template <
typename T1,
typename T2>
3721template <
typename T1,
typename T2>
3724template <
typename... Ts>
3727template <
typename... Ts>
3730template<
typename T,
typename =
void>
3752 using t_ref =
typename std::add_lvalue_reference<T>::type;
3760 static constexpr auto is_iterator_begin =
3764 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
3777template<
typename T,
typename =
void>
3783template<
typename BasicJsonType,
typename CompatibleObjectType,
3787template<
typename BasicJsonType,
typename CompatibleObjectType>
3789 BasicJsonType, CompatibleObjectType,
3798 typename CompatibleObjectType::key_type>
::value &&
3800 typename CompatibleObjectType::mapped_type>
::value;
3803template<
typename BasicJsonType,
typename CompatibleObjectType>
3807template<
typename BasicJsonType,
typename ConstructibleObjectType,
3811template<
typename BasicJsonType,
typename ConstructibleObjectType>
3813 BasicJsonType, ConstructibleObjectType,
3821 (std::is_move_assignable<ConstructibleObjectType>::value ||
3822 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3824 typename object_t::key_type>
::value &&
3826 typename object_t::mapped_type,
3827 typename ConstructibleObjectType::mapped_type >
::value)) ||
3829 typename ConstructibleObjectType::mapped_type>
::value ||
3832 typename ConstructibleObjectType::mapped_type >
::value);
3835template<
typename BasicJsonType,
typename ConstructibleObjectType>
3838 ConstructibleObjectType> {};
3840template<
typename BasicJsonType,
typename CompatibleStringType>
3847template<
typename BasicJsonType,
typename ConstructibleStringType>
3851#ifdef __INTEL_COMPILER
3852 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3864template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3867template<
typename BasicJsonType,
typename CompatibleArrayType>
3869 BasicJsonType, CompatibleArrayType,
3875 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3882template<
typename BasicJsonType,
typename CompatibleArrayType>
3886template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3889template<
typename BasicJsonType,
typename ConstructibleArrayType>
3891 BasicJsonType, ConstructibleArrayType,
3893 typename BasicJsonType::value_type>
::value >>
3894 : std::true_type {};
3896template<
typename BasicJsonType,
typename ConstructibleArrayType>
3898 BasicJsonType, ConstructibleArrayType,
3900 typename BasicJsonType::value_type>
::value&&
3903(std::is_move_assignable<ConstructibleArrayType>::value ||
3904 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3910!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3912 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3918 typename BasicJsonType::array_t::value_type>
::value ||
3926template<
typename BasicJsonType,
typename ConstructibleArrayType>
3930template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3934template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3936 RealIntegerType, CompatibleNumberIntegerType,
3938 std::is_integral<CompatibleNumberIntegerType>
::value&&
3939 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3947 CompatibleNumberIntegerType>
::value &&
3948 CompatibleLimits::is_integer &&
3949 RealLimits::is_signed == CompatibleLimits::is_signed;
3952template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3955 CompatibleNumberIntegerType> {};
3957template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3960template<
typename BasicJsonType,
typename CompatibleType>
3962 BasicJsonType, CompatibleType,
3969template<
typename BasicJsonType,
typename CompatibleType>
3973template<
typename T1,
typename T2>
3976template<
typename T1,
typename... Args>
3979template<
typename BasicJsonType,
typename T>
3982template<
typename BasicJsonType>
3985template<
typename BasicJsonType>
3990template<
template <
typename...>
class Primary,
typename T>
3993template<
template <
typename...>
class Primary,
typename... Args>
4000template<
typename Compare,
typename A,
typename B,
typename =
void>
4003template<
typename Compare,
typename A,
typename B>
4005decltype(
std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
4006decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
4007>> : std::true_type {};
4014template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4018 && !(ExcludeObjectKeyType && std::is_same<KeyType,
4020 && (!RequireTransparentComparator
4021 || is_detected <detect_is_transparent, Comparator>::value)
4024 std::false_type >::type;
4032template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
4036 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
4037 RequireTransparentComparator, ExcludeObjectKeyType>
::value
4040 std::false_type >::type;
4042template<
typename ObjectType,
typename KeyType>
4046template<
typename BasicJsonType,
typename KeyType>
4050 typename BasicJsonType::object_t, KeyType >
::value,
4052 std::false_type >::type;
4056template <
typename T>
4066 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
4073template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
4076 return static_cast<T
>(
value);
4079template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
4085template<
typename... Types>
4088template<
typename... Types>
4091template<
typename... Types>
4095template<
typename... Types>
4099template<
typename OfType,
typename T>
4101 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4104template<
typename OfType,
typename T,
4105 bool OfTypeSigned = std::is_signed<OfType>::value,
4106 bool TSigned = std::is_signed<T>::value>
4109template<
typename OfType,
typename T>
4114 using CommonType =
typename std::common_type<OfType, T>::type;
4115 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4119template<
typename OfType,
typename T>
4124 using CommonType =
typename std::common_type<OfType, T>::type;
4125 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4129template<
typename OfType,
typename T>
4134 using CommonType =
typename std::common_type<OfType, T>::type;
4135 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4139template<
typename OfType,
typename T>
4144 using CommonType =
typename std::common_type<OfType, T>::type;
4145 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4146 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4150template<
typename OfType,
typename T,
4151 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4155template<
typename OfType,
typename T>
4164template<
typename OfType,
typename T>
4173template<
typename OfType,
typename T>
4192 using TUnExt =
typename std::remove_extent<T>::type;
4193 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4194 using TUnPtr =
typename std::remove_pointer<T>::type;
4195 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4197 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4198 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4263template<
typename... Args>
4264inline std::size_t
concat_length(
const char* cstr,
const Args& ... rest);
4266template<
typename StringType,
typename... Args>
4267inline std::size_t
concat_length(
const StringType& str,
const Args& ... rest);
4269template<
typename... Args>
4275template<
typename... Args>
4282template<
typename StringType,
typename... Args>
4288template<
typename OutStringType>
4292template<
typename StringType,
typename Arg>
4295template<
typename StringType,
typename Arg>
4298template<
typename StringType,
typename Arg>
4301template<
typename StringType,
typename Arg>
4304template<
typename StringType,
typename Arg>
4305using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4307template<
typename StringType,
typename Arg>
4310template<
typename StringType,
typename Arg>
4311using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4313template<
typename StringType,
typename Arg>
4316template <
typename OutStringType,
typename Arg,
typename... Args,
4317 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4319inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4321template <
typename OutStringType,
typename Arg,
typename... Args,
4322 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4325inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4327template <
typename OutStringType,
typename Arg,
typename... Args,
4328 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4332inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4334template<
typename OutStringType,
typename Arg,
typename... Args,
4336inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4338 out.append(std::forward<Arg>(arg));
4342template <
typename OutStringType,
typename Arg,
typename... Args,
4343 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4344 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4345inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4347 out += std::forward<Arg>(arg);
4351template <
typename OutStringType,
typename Arg,
typename... Args,
4352 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4353 && !detect_string_can_append_op<OutStringType, Arg>::value
4354 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4355inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4357 out.append(arg.begin(), arg.end());
4361template <
typename OutStringType,
typename Arg,
typename... Args,
4362 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4363 && !detect_string_can_append_op<OutStringType, Arg>::value
4364 && !detect_string_can_append_iter<OutStringType, Arg>::value
4365 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4366inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4368 out.append(arg.data(), arg.size());
4372template<
typename OutStringType = std::string,
typename... Args>
4399 const char*
what() const noexcept
override
4409 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
4411 static std::string
name(
const std::string& ename,
int id_)
4413 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4421 template<
typename BasicJsonType>
4425 std::vector<std::string> tokens;
4426 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4428 switch (current->m_parent->type())
4432 for (std::size_t i = 0; i < current->m_parent->m_data.m_value.array->size(); ++i)
4434 if (¤t->m_parent->m_data.m_value.array->operator[](i) == current)
4436 tokens.emplace_back(std::to_string(i));
4445 for (
const auto& element : *current->m_parent->m_data.m_value.object)
4447 if (&element.second == current)
4449 tokens.emplace_back(element.first.c_str());
4474 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4475 [](
const std::string & a,
const std::string & b)
4477 return concat(a,
'/', detail::escape(b));
4479 return concat(
'(', str,
") ");
4481 static_cast<void>(leaf_element);
4488 std::runtime_error m;
4505 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4513 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4514 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg, BasicJsonContext context)
4517 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4519 return {id_, byte_, w.c_str()};
4534 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
4537 static std::string position_string(
const position_t& pos)
4549 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4553 return {id_, w.c_str()};
4567 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4571 return {id_, w.c_str()};
4584 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4588 return {id_, w.c_str()};
4601 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4605 return {id_, w.c_str()};
4658#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4659#include <experimental/filesystem>
4663namespace std_fs = std::experimental::filesystem;
4666#elif JSON_HAS_FILESYSTEM
4667#include <filesystem>
4671namespace std_fs = std::filesystem;
4687template<
typename BasicJsonType>
4688inline void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
4698template <
typename BasicJsonType,
typename ArithmeticType,
4699 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4700 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4704 switch (
static_cast<value_t>(j))
4708 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4713 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4718 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4734template<
typename BasicJsonType>
4735inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4741 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4744template<
typename BasicJsonType>
4745inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4751 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4755 typename BasicJsonType,
typename StringType,
4757 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4758 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4759 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4760 && !is_json_ref<StringType>::value,
int > = 0 >
4768 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4771template<
typename BasicJsonType>
4772inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4777template<
typename BasicJsonType>
4778inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4783template<
typename BasicJsonType>
4784inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4789#if !JSON_DISABLE_ENUM_SERIALIZATION
4790template<
typename BasicJsonType,
typename EnumType,
4791 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4794 typename std::underlying_type<EnumType>::type val;
4796 e =
static_cast<EnumType
>(val);
4801template<
typename BasicJsonType,
typename T,
typename Allocator,
4802 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4803inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4810 std::transform(j.rbegin(), j.rend(),
4811 std::front_inserter(l), [](
const BasicJsonType & i)
4813 return i.template get<T>();
4818template<
typename BasicJsonType,
typename T,
4819 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4820inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4827 std::transform(j.begin(), j.end(), std::begin(l),
4828 [](
const BasicJsonType & elem)
4830 return elem.template get<T>();
4834template<
typename BasicJsonType,
typename T, std::
size_t N>
4836->
decltype(j.template
get<T>(), void())
4838 for (std::size_t i = 0; i < N; ++i)
4840 arr[i] = j.at(i).template
get<T>();
4844template<
typename BasicJsonType>
4847 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4850template<
typename BasicJsonType,
typename T, std::
size_t N>
4853->
decltype(j.template
get<T>(), void())
4855 for (std::size_t i = 0; i < N; ++i)
4857 arr[i] = j.at(i).template
get<T>();
4861template<
typename BasicJsonType,
typename ConstructibleArrayType,
4863 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4867 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4873 ConstructibleArrayType ret;
4874 ret.reserve(j.size());
4875 std::transform(j.begin(), j.end(),
4876 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4882 arr = std::move(ret);
4885template<
typename BasicJsonType,
typename ConstructibleArrayType,
4887 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4894 ConstructibleArrayType ret;
4896 j.begin(), j.end(), std::inserter(ret, end(ret)),
4897 [](
const BasicJsonType & i)
4903 arr = std::move(ret);
4906template <
typename BasicJsonType,
typename ConstructibleArrayType,
4908 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4909 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4911 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4912 !is_basic_json<ConstructibleArrayType>::value,
4914auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4927template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4931 return { { std::forward<BasicJsonType>(j).at(Idx).template
get<T>()... } };
4934template <
typename BasicJsonType,
typename T, std::
size_t N >
4946template<
typename BasicJsonType>
4947inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4954 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4957template<
typename BasicJsonType,
typename ConstructibleObjectType,
4958 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4959inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4966 ConstructibleObjectType ret;
4967 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4968 using value_type =
typename ConstructibleObjectType::value_type;
4970 inner_object->begin(), inner_object->end(),
4971 std::inserter(ret, ret.begin()),
4972 [](
typename BasicJsonType::object_t::value_type
const & p)
4974 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4976 obj = std::move(ret);
4983template <
typename BasicJsonType,
typename ArithmeticType,
4985 std::is_arithmetic<ArithmeticType>::value&&
4986 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4987 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4988 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4989 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4991inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4993 switch (
static_cast<value_t>(j))
4997 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
5002 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
5007 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
5012 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
5027template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
5030 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
5033template <
typename BasicJsonType,
class A1,
class A2 >
5036 return {std::forward<BasicJsonType>(j).at(0).template
get<A1>(),
5037 std::forward<BasicJsonType>(j).at(1).template
get<A2>()};
5040template<
typename BasicJsonType,
typename A1,
typename A2>
5046template<
typename BasicJsonType,
typename... Args>
5052template<
typename BasicJsonType,
typename... Args>
5058template<
typename BasicJsonType,
typename TupleRelated>
5067 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
5070template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
5072 typename BasicJsonType::string_t, Key >
::value >>
5073inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
5080 for (
const auto& p : j)
5090template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5092 typename BasicJsonType::string_t, Key >
::value >>
5093inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5100 for (
const auto& p : j)
5110#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5111template<
typename BasicJsonType>
5112inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5118 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5124 template<
typename BasicJsonType,
typename T>
5126 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5127 ->
decltype(
from_json(j, std::forward<T>(val)))
5129 return from_json(j, std::forward<T>(val));
5135#ifndef JSON_HAS_CPP_17
5144#ifndef JSON_HAS_CPP_17
5165#include <type_traits>
5202template<
typename string_type>
5206 using std::to_string;
5209template<
typename IteratorType>
class iteration_proxy_value
5217 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5221 IteratorType anchor{};
5223 std::size_t array_index = 0;
5225 mutable std::size_t array_index_last = 0;
5234 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5236 : anchor(
std::move(it))
5237 , array_index(array_index_)
5244 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5247 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5277 return anchor == o.anchor;
5283 return anchor != o.anchor;
5291 switch (anchor.m_object->type())
5296 if (array_index != array_index_last)
5299 array_index_last = array_index;
5301 return array_index_str;
5306 return anchor.key();
5323 typename IteratorType::reference
value()
const
5325 return anchor.value();
5330template<
typename IteratorType>
class iteration_proxy
5334 typename IteratorType::pointer container =
nullptr;
5341 : container(&cont) {}
5365template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5366auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5373template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5374auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5389#if defined(__clang__)
5391 #pragma clang diagnostic push
5392 #pragma clang diagnostic ignored "-Wmismatched-tags"
5394template<
typename IteratorType>
5395class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5396 :
public std::integral_constant<std::size_t, 2> {};
5398template<std::
size_t N,
typename IteratorType>
5399class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5403 get<N>(std::declval <
5404 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5406#if defined(__clang__)
5407 #pragma clang diagnostic pop
5413 template <
typename IteratorType>
5414 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5448 template<
typename BasicJsonType>
5449 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5451 j.m_data.m_value.destroy(j.m_data.m_type);
5453 j.m_data.m_value = b;
5454 j.assert_invariant();
5461 template<
typename BasicJsonType>
5462 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5464 j.m_data.m_value.destroy(j.m_data.m_type);
5466 j.m_data.m_value = s;
5467 j.assert_invariant();
5470 template<
typename BasicJsonType>
5471 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5473 j.m_data.m_value.destroy(j.m_data.m_type);
5475 j.m_data.m_value = std::move(s);
5476 j.assert_invariant();
5479 template <
typename BasicJsonType,
typename CompatibleStringType,
5480 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5482 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5484 j.m_data.m_value.destroy(j.m_data.m_type);
5486 j.m_data.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5487 j.assert_invariant();
5494 template<
typename BasicJsonType>
5495 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5497 j.m_data.m_value.destroy(j.m_data.m_type);
5499 j.m_data.m_value =
typename BasicJsonType::binary_t(b);
5500 j.assert_invariant();
5503 template<
typename BasicJsonType>
5504 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5506 j.m_data.m_value.destroy(j.m_data.m_type);
5508 j.m_data.m_value =
typename BasicJsonType::binary_t(std::move(b));
5509 j.assert_invariant();
5516 template<
typename BasicJsonType>
5517 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5519 j.m_data.m_value.destroy(j.m_data.m_type);
5521 j.m_data.m_value = val;
5522 j.assert_invariant();
5529 template<
typename BasicJsonType>
5530 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5532 j.m_data.m_value.destroy(j.m_data.m_type);
5534 j.m_data.m_value = val;
5535 j.assert_invariant();
5542 template<
typename BasicJsonType>
5543 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5545 j.m_data.m_value.destroy(j.m_data.m_type);
5547 j.m_data.m_value = val;
5548 j.assert_invariant();
5555 template<
typename BasicJsonType>
5556 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5558 j.m_data.m_value.destroy(j.m_data.m_type);
5560 j.m_data.m_value = arr;
5562 j.assert_invariant();
5565 template<
typename BasicJsonType>
5566 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5568 j.m_data.m_value.destroy(j.m_data.m_type);
5570 j.m_data.m_value = std::move(arr);
5572 j.assert_invariant();
5575 template <
typename BasicJsonType,
typename CompatibleArrayType,
5576 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5578 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5583 j.m_data.m_value.destroy(j.m_data.m_type);
5585 j.m_data.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5587 j.assert_invariant();
5590 template<
typename BasicJsonType>
5591 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5593 j.m_data.m_value.destroy(j.m_data.m_type);
5596 j.m_data.m_value.array->reserve(arr.size());
5597 for (
const bool x : arr)
5599 j.m_data.m_value.array->push_back(x);
5600 j.set_parent(j.m_data.m_value.array->back());
5602 j.assert_invariant();
5605 template<
typename BasicJsonType,
typename T,
5607 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5609 j.m_data.m_value.destroy(j.m_data.m_type);
5612 j.m_data.m_value.array->resize(arr.size());
5615 std::copy(std::begin(arr), std::end(arr), j.m_data.m_value.array->begin());
5618 j.assert_invariant();
5625 template<
typename BasicJsonType>
5626 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5628 j.m_data.m_value.destroy(j.m_data.m_type);
5630 j.m_data.m_value = obj;
5632 j.assert_invariant();
5635 template<
typename BasicJsonType>
5636 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5638 j.m_data.m_value.destroy(j.m_data.m_type);
5640 j.m_data.m_value = std::move(obj);
5642 j.assert_invariant();
5645 template <
typename BasicJsonType,
typename CompatibleObjectType,
5646 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5647 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5652 j.m_data.m_value.destroy(j.m_data.m_type);
5654 j.m_data.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5656 j.assert_invariant();
5664template<
typename BasicJsonType,
typename T,
5665 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5666inline void to_json(BasicJsonType& j, T b)
noexcept
5671template <
typename BasicJsonType,
typename BoolRef,
5673 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5674 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5675 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5676 && !std::is_same <detail::uncvref_t<std::vector<bool>::const_reference>,
5677 typename BasicJsonType::boolean_t >
::value))
5678 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5679inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5684template<
typename BasicJsonType,
typename CompatibleString,
5685 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5686inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5691template<
typename BasicJsonType>
5692inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5697template<
typename BasicJsonType,
typename FloatType,
5698 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5699inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5704template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5705 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5706inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5711template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5712 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5713inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5718#if !JSON_DISABLE_ENUM_SERIALIZATION
5719template<
typename BasicJsonType,
typename EnumType,
5720 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5721inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5723 using underlying_type =
typename std::underlying_type<EnumType>::type;
5728template<
typename BasicJsonType>
5729inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5734template <
typename BasicJsonType,
typename CompatibleArrayType,
5735 enable_if_t < is_compatible_array_type<BasicJsonType,
5737 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5739 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5740 !is_basic_json<CompatibleArrayType>::value,
5742inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5747template<
typename BasicJsonType>
5748inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5753template<
typename BasicJsonType,
typename T,
5754 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5755inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5760template<
typename BasicJsonType>
5761inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5766template <
typename BasicJsonType,
typename CompatibleObjectType,
5767 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5768inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5773template<
typename BasicJsonType>
5774inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5780 typename BasicJsonType,
typename T, std::size_t N,
5781 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5784inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5789template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5790inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5792 j = { p.first, p.second };
5796template<
typename BasicJsonType,
typename T,
5800 j = { {b.key(), b.value()} };
5803template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
5806 j = { std::get<Idx>(t)... };
5809template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5810inline void to_json(BasicJsonType& j,
const T& t)
5815#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5816template<
typename BasicJsonType>
5817inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5825 template<
typename BasicJsonType,
typename T>
5826 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5827 ->
decltype(
to_json(j, std::forward<T>(val)),
void())
5829 return to_json(j, std::forward<T>(val));
5834#ifndef JSON_HAS_CPP_17
5843#ifndef JSON_HAS_CPP_17
5855template<
typename ValueType,
typename>
5860 template<
typename BasicJsonType,
typename TargetType = ValueType>
5861 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5862 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5863 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val),
void())
5865 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5870 template<
typename BasicJsonType,
typename TargetType = ValueType>
5880 template<
typename BasicJsonType,
typename TargetType = ValueType>
5881 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5882 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5883 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)),
void())
5885 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5913template<
typename BinaryType>
5938 , m_subtype(subtype_)
5939 , m_has_subtype(true)
5945 , m_subtype(subtype_)
5946 , m_has_subtype(true)
5951 return std::tie(
static_cast<const BinaryType&
>(*
this), m_subtype, m_has_subtype) ==
5952 std::tie(
static_cast<const BinaryType&
>(rhs), rhs.m_subtype, rhs.m_has_subtype);
5957 return !(rhs == *
this);
5964 m_subtype = subtype_;
5965 m_has_subtype =
true;
5972 return m_has_subtype ? m_subtype :
static_cast<subtype_type>(-1);
5979 return m_has_subtype;
5987 m_has_subtype =
false;
5992 bool m_has_subtype =
false;
6016#include <functional>
6028inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
6030 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
6045template<
typename BasicJsonType>
6046std::size_t
hash(
const BasicJsonType& j)
6048 using string_t =
typename BasicJsonType::string_t;
6049 using number_integer_t =
typename BasicJsonType::number_integer_t;
6050 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
6051 using number_float_t =
typename BasicJsonType::number_float_t;
6053 const auto type =
static_cast<std::size_t
>(j.type());
6056 case BasicJsonType::value_t::null:
6057 case BasicJsonType::value_t::discarded:
6062 case BasicJsonType::value_t::object:
6064 auto seed =
combine(type, j.size());
6065 for (
const auto& element : j.items())
6067 const auto h = std::hash<string_t> {}(element.key());
6074 case BasicJsonType::value_t::array:
6076 auto seed =
combine(type, j.size());
6077 for (
const auto& element : j)
6084 case BasicJsonType::value_t::string:
6086 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
6090 case BasicJsonType::value_t::boolean:
6092 const auto h = std::hash<bool> {}(j.template
get<bool>());
6096 case BasicJsonType::value_t::number_integer:
6102 case BasicJsonType::value_t::number_unsigned:
6108 case BasicJsonType::value_t::number_float:
6114 case BasicJsonType::value_t::binary:
6116 auto seed =
combine(type, j.get_binary().size());
6117 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6119 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
6120 for (
const auto byte : j.get_binary())
6122 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6180#include <type_traits>
6232 return std::fgetc(m_file);
6260 is->clear(is->rdstate() & std::ios::eofbit);
6265 : is(&i), sb(i.rdbuf())
6274 : is(rhs.is), sb(rhs.sb)
6285 auto res = sb->sbumpc();
6289 is->clear(is->rdstate() | std::ios::eofbit);
6296 std::istream* is =
nullptr;
6297 std::streambuf* sb =
nullptr;
6303template<
typename IteratorType>
6307 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6310 : current(
std::move(first)), end(
std::move(last))
6318 std::advance(current, 1);
6326 IteratorType current;
6329 template<
typename BaseInputAdapter,
size_t T>
6334 return current == end;
6338template<
typename BaseInputAdapter,
size_t T>
6341template<
typename BaseInputAdapter>
6346 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6347 size_t& utf8_bytes_index,
6348 size_t& utf8_bytes_filled)
6350 utf8_bytes_index = 0;
6354 utf8_bytes[0] = std::char_traits<char>::eof();
6355 utf8_bytes_filled = 1;
6360 const auto wc = input.get_character();
6365 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6366 utf8_bytes_filled = 1;
6368 else if (wc <= 0x7FF)
6370 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
6371 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6372 utf8_bytes_filled = 2;
6374 else if (wc <= 0xFFFF)
6376 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
6377 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6378 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6379 utf8_bytes_filled = 3;
6381 else if (wc <= 0x10FFFF)
6383 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
6384 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
6385 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6386 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6387 utf8_bytes_filled = 4;
6392 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6393 utf8_bytes_filled = 1;
6399template<
typename BaseInputAdapter>
6404 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
6405 size_t& utf8_bytes_index,
6406 size_t& utf8_bytes_filled)
6408 utf8_bytes_index = 0;
6412 utf8_bytes[0] = std::char_traits<char>::eof();
6413 utf8_bytes_filled = 1;
6418 const auto wc = input.get_character();
6423 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6424 utf8_bytes_filled = 1;
6426 else if (wc <= 0x7FF)
6428 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
6429 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6430 utf8_bytes_filled = 2;
6432 else if (0xD800 > wc || wc >= 0xE000)
6434 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
6435 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
6436 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
6437 utf8_bytes_filled = 3;
6443 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6444 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6445 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
6446 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
6447 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
6448 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
6449 utf8_bytes_filled = 4;
6453 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
6454 utf8_bytes_filled = 1;
6462template<
typename BaseInputAdapter,
typename W
ideCharType>
6469 : base_adapter(base) {}
6474 if (utf8_bytes_index == utf8_bytes_filled)
6476 fill_buffer<sizeof(WideCharType)>();
6484 JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
6485 return utf8_bytes[utf8_bytes_index++];
6489 BaseInputAdapter base_adapter;
6498 std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
6501 std::size_t utf8_bytes_index = 0;
6503 std::size_t utf8_bytes_filled = 0;
6506template<
typename IteratorType,
typename Enable =
void>
6510 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6515 return adapter_type(std::move(first), std::move(last));
6529template<
typename IteratorType>
6533 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6544template<
typename IteratorType>
6548 return factory_type::create(first, last);
6555namespace container_input_adapter_factory_impl
6561template<
typename ContainerType,
typename Enable =
void>
6564template<
typename ContainerType>
6566 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6578template<
typename ContainerType>
6605template <
typename CharT,
6606 typename std::enable_if <
6607 std::is_pointer<CharT>::value&&
6608 !std::is_array<CharT>::value&&
6609 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6610 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6614 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6615 const auto* ptr =
reinterpret_cast<const char*
>(b);
6619template<
typename T, std::
size_t N>
6631 template <
typename CharT,
6632 typename std::enable_if <
6633 std::is_pointer<CharT>::value&&
6634 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6635 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6638 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6640 template<
class IteratorType,
6641 typename std::enable_if<
6642 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6649 return std::move(ia);
6692template<
typename BasicJsonType>
6796 const std::string& last_token,
6822template<
typename BasicJsonType>
6838 : root(r), allow_exceptions(allow_exceptions_)
6850 handle_value(
nullptr);
6886 handle_value(std::move(val));
6892 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6894 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6896 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
6908 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
6917 ref_stack.back()->set_parents();
6918 ref_stack.pop_back();
6924 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6926 if (
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
6928 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
6939 ref_stack.back()->set_parents();
6940 ref_stack.pop_back();
6944 template<
class Exception>
6946 const Exception& ex)
6949 static_cast<void>(ex);
6950 if (allow_exceptions)
6969 template<
typename Value>
6971 BasicJsonType* handle_value(Value&& v)
6973 if (ref_stack.empty())
6975 root = BasicJsonType(std::forward<Value>(v));
6979 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6981 if (ref_stack.back()->is_array())
6983 ref_stack.back()->m_data.m_value.array->emplace_back(std::forward<Value>(v));
6984 return &(ref_stack.back()->m_data.m_value.array->back());
6989 *object_element = BasicJsonType(std::forward<Value>(v));
6990 return object_element;
6994 BasicJsonType& root;
6996 std::vector<BasicJsonType*> ref_stack {};
6998 BasicJsonType* object_element =
nullptr;
7000 bool errored =
false;
7002 const bool allow_exceptions =
true;
7005template<
typename BasicJsonType>
7019 const bool allow_exceptions_ =
true)
7020 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
7022 keep_stack.push_back(
true);
7034 handle_value(
nullptr);
7070 handle_value(std::move(val));
7077 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
7078 keep_stack.push_back(keep);
7080 auto val = handle_value(BasicJsonType::value_t::object,
true);
7081 ref_stack.push_back(val.second);
7084 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7086 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7094 BasicJsonType k = BasicJsonType(val);
7097 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7098 key_keep_stack.push_back(keep);
7101 if (keep && ref_stack.back())
7103 object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) =
discarded);
7111 if (ref_stack.back())
7113 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7120 ref_stack.back()->set_parents();
7126 ref_stack.pop_back();
7127 keep_stack.pop_back();
7129 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7132 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7134 if (it->is_discarded())
7136 ref_stack.back()->erase(it);
7147 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7148 keep_stack.push_back(keep);
7150 auto val = handle_value(BasicJsonType::value_t::array,
true);
7151 ref_stack.push_back(val.second);
7154 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len !=
static_cast<std::size_t
>(-1) && len > ref_stack.back()->max_size()))
7156 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7166 if (ref_stack.back())
7168 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7171 ref_stack.back()->set_parents();
7182 ref_stack.pop_back();
7183 keep_stack.pop_back();
7186 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7188 ref_stack.back()->m_data.m_value.array->pop_back();
7194 template<
class Exception>
7196 const Exception& ex)
7199 static_cast<void>(ex);
7200 if (allow_exceptions)
7228 template<
typename Value>
7229 std::pair<bool, BasicJsonType*> handle_value(Value&& v,
const bool skip_callback =
false)
7235 if (!keep_stack.back())
7237 return {
false,
nullptr};
7241 auto value = BasicJsonType(std::forward<Value>(v));
7244 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value, value);
7249 return {
false,
nullptr};
7252 if (ref_stack.empty())
7254 root = std::move(value);
7255 return {
true, & root};
7260 if (!ref_stack.back())
7262 return {
false,
nullptr};
7266 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7269 if (ref_stack.back()->is_array())
7271 ref_stack.back()->m_data.m_value.array->emplace_back(std::move(value));
7272 return {
true, & (ref_stack.back()->m_data.m_value.array->back())};
7279 const bool store_element = key_keep_stack.back();
7280 key_keep_stack.pop_back();
7284 return {
false,
nullptr};
7288 *object_element = std::move(value);
7289 return {
true, object_element};
7293 BasicJsonType& root;
7295 std::vector<BasicJsonType*> ref_stack {};
7297 std::vector<bool> keep_stack {};
7299 std::vector<bool> key_keep_stack {};
7301 BasicJsonType* object_element =
nullptr;
7303 bool errored =
false;
7307 const bool allow_exceptions =
true;
7309 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7312template<
typename BasicJsonType>
7407#include <initializer_list>
7429template<
typename BasicJsonType>
7462 case token_type::uninitialized:
7463 return "<uninitialized>";
7464 case token_type::literal_true:
7465 return "true literal";
7466 case token_type::literal_false:
7467 return "false literal";
7468 case token_type::literal_null:
7469 return "null literal";
7470 case token_type::value_string:
7471 return "string literal";
7472 case token_type::value_unsigned:
7473 case token_type::value_integer:
7474 case token_type::value_float:
7475 return "number literal";
7476 case token_type::begin_array:
7478 case token_type::begin_object:
7480 case token_type::end_array:
7482 case token_type::end_object:
7484 case token_type::name_separator:
7486 case token_type::value_separator:
7488 case token_type::parse_error:
7489 return "<parse error>";
7490 case token_type::end_of_input:
7491 return "end of input";
7492 case token_type::literal_or_value:
7493 return "'[', '{', or a literal";
7496 return "unknown token";
7506template<
typename BasicJsonType,
typename InputAdapterType>
7509 using number_integer_t =
typename BasicJsonType::number_integer_t;
7510 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
7511 using number_float_t =
typename BasicJsonType::number_float_t;
7512 using string_t =
typename BasicJsonType::string_t;
7513 using char_type =
typename InputAdapterType::char_type;
7519 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7520 : ia(
std::move(adapter))
7521 , ignore_comments(ignore_comments_)
7522 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7539 static char get_decimal_point() noexcept
7541 const auto* loc = localeconv();
7543 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7571 const auto factors = { 12u, 8u, 4u, 0u };
7572 for (
const auto factor : factors)
7576 if (current >=
'0' && current <=
'9')
7578 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7580 else if (current >=
'A' && current <=
'F')
7582 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7584 else if (current >=
'a' && current <=
'f')
7586 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7594 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7613 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
7615 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7618 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7627 error_message =
"invalid string: ill-formed UTF-8 byte";
7650 token_type scan_string()
7664 case char_traits<char_type>::eof():
7666 error_message =
"invalid string: missing closing quote";
7667 return token_type::parse_error;
7673 return token_type::value_string;
7717 const int codepoint1 = get_codepoint();
7718 int codepoint = codepoint1;
7722 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7723 return token_type::parse_error;
7727 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7732 const int codepoint2 = get_codepoint();
7736 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7737 return token_type::parse_error;
7744 codepoint =
static_cast<int>(
7746 (
static_cast<unsigned int>(codepoint1) << 10u)
7748 +
static_cast<unsigned int>(codepoint2)
7756 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7757 return token_type::parse_error;
7762 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7763 return token_type::parse_error;
7770 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7771 return token_type::parse_error;
7776 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7779 if (codepoint < 0x80)
7782 add(
static_cast<char_int_type
>(codepoint));
7784 else if (codepoint <= 0x7FF)
7787 add(
static_cast<char_int_type
>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7788 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7790 else if (codepoint <= 0xFFFF)
7793 add(
static_cast<char_int_type
>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7794 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7795 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7800 add(
static_cast<char_int_type
>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7801 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7802 add(
static_cast<char_int_type
>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7803 add(
static_cast<char_int_type
>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7811 error_message =
"invalid string: forbidden character after backslash";
7812 return token_type::parse_error;
7821 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7822 return token_type::parse_error;
7827 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7828 return token_type::parse_error;
7833 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7834 return token_type::parse_error;
7839 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7840 return token_type::parse_error;
7845 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7846 return token_type::parse_error;
7851 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7852 return token_type::parse_error;
7857 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7858 return token_type::parse_error;
7863 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7864 return token_type::parse_error;
7869 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7870 return token_type::parse_error;
7875 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7876 return token_type::parse_error;
7881 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7882 return token_type::parse_error;
7887 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7888 return token_type::parse_error;
7893 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7894 return token_type::parse_error;
7899 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7900 return token_type::parse_error;
7905 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7906 return token_type::parse_error;
7911 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7912 return token_type::parse_error;
7917 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7918 return token_type::parse_error;
7923 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7924 return token_type::parse_error;
7929 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7930 return token_type::parse_error;
7935 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7936 return token_type::parse_error;
7941 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7942 return token_type::parse_error;
7947 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7948 return token_type::parse_error;
7953 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7954 return token_type::parse_error;
7959 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7960 return token_type::parse_error;
7965 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7966 return token_type::parse_error;
7971 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7972 return token_type::parse_error;
7977 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7978 return token_type::parse_error;
7983 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7984 return token_type::parse_error;
7989 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7990 return token_type::parse_error;
7995 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7996 return token_type::parse_error;
8001 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
8002 return token_type::parse_error;
8007 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
8008 return token_type::parse_error;
8145 return token_type::parse_error;
8155 return token_type::parse_error;
8179 return token_type::parse_error;
8189 return token_type::parse_error;
8199 return token_type::parse_error;
8211 return token_type::parse_error;
8221 return token_type::parse_error;
8229 error_message =
"invalid string: ill-formed UTF-8 byte";
8230 return token_type::parse_error;
8253 case char_traits<char_type>::eof():
8270 case char_traits<char_type>::eof():
8273 error_message =
"invalid comment; missing closing '*/'";
8301 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8308 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8310 f = std::strtof(str, endptr);
8314 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8316 f = std::strtod(str, endptr);
8320 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8322 f = std::strtold(str, endptr);
8365 token_type scan_number()
8372 token_type number_type = token_type::value_unsigned;
8380 goto scan_number_minus;
8386 goto scan_number_zero;
8400 goto scan_number_any1;
8410 number_type = token_type::value_integer;
8416 goto scan_number_zero;
8430 goto scan_number_any1;
8435 error_message =
"invalid number; expected digit after '-'";
8436 return token_type::parse_error;
8446 add(decimal_point_char);
8447 goto scan_number_decimal1;
8454 goto scan_number_exponent;
8458 goto scan_number_done;
8477 goto scan_number_any1;
8482 add(decimal_point_char);
8483 goto scan_number_decimal1;
8490 goto scan_number_exponent;
8494 goto scan_number_done;
8497scan_number_decimal1:
8499 number_type = token_type::value_float;
8514 goto scan_number_decimal2;
8519 error_message =
"invalid number; expected digit after '.'";
8520 return token_type::parse_error;
8524scan_number_decimal2:
8540 goto scan_number_decimal2;
8547 goto scan_number_exponent;
8551 goto scan_number_done;
8554scan_number_exponent:
8556 number_type = token_type::value_float;
8563 goto scan_number_sign;
8578 goto scan_number_any2;
8584 "invalid number; expected '+', '-', or digit after exponent";
8585 return token_type::parse_error;
8605 goto scan_number_any2;
8610 error_message =
"invalid number; expected digit after exponent sign";
8611 return token_type::parse_error;
8631 goto scan_number_any2;
8635 goto scan_number_done;
8643 char* endptr =
nullptr;
8647 if (number_type == token_type::value_unsigned)
8649 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8652 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8656 value_unsigned =
static_cast<number_unsigned_t
>(x);
8657 if (value_unsigned == x)
8659 return token_type::value_unsigned;
8663 else if (number_type == token_type::value_integer)
8665 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8668 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8672 value_integer =
static_cast<number_integer_t
>(x);
8673 if (value_integer == x)
8675 return token_type::value_integer;
8682 strtof(value_float, token_buffer.data(), &endptr);
8685 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8687 return token_type::value_float;
8696 token_type scan_literal(const char_type* literal_text, const
std::
size_t length,
8697 token_type return_type)
8699 JSON_ASSERT(char_traits<char_type>::to_char_type(current) == literal_text[0]);
8700 for (std::size_t i = 1; i < length; ++i)
8704 error_message =
"invalid literal";
8705 return token_type::parse_error;
8716 void reset() noexcept
8718 token_buffer.clear();
8719 token_string.clear();
8720 token_string.push_back(char_traits<char_type>::to_char_type(current));
8735 ++position.chars_read_total;
8736 ++position.chars_read_current_line;
8745 current = ia.get_character();
8750 token_string.push_back(char_traits<char_type>::to_char_type(current));
8753 if (current ==
'\n')
8755 ++position.lines_read;
8756 position.chars_read_current_line = 0;
8774 --position.chars_read_total;
8777 if (position.chars_read_current_line == 0)
8779 if (position.lines_read > 0)
8781 --position.lines_read;
8786 --position.chars_read_current_line;
8792 token_string.pop_back();
8797 void add(char_int_type c)
8799 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8810 return value_integer;
8816 return value_unsigned;
8828 return token_buffer;
8848 for (
const auto c : token_string)
8850 if (
static_cast<unsigned char>(c) <=
'\x1F')
8853 std::array<char, 9> cs{{}};
8854 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8855 result += cs.data();
8860 result.push_back(
static_cast<std::string::value_type
>(c));
8871 return error_message;
8887 return get() == 0xBB &&
get() == 0xBF;
8902 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8908 if (position.chars_read_total == 0 && !skip_bom())
8910 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8911 return token_type::parse_error;
8918 while (ignore_comments && current ==
'/')
8920 if (!scan_comment())
8922 return token_type::parse_error;
8933 return token_type::begin_array;
8935 return token_type::end_array;
8937 return token_type::begin_object;
8939 return token_type::end_object;
8941 return token_type::name_separator;
8943 return token_type::value_separator;
8948 std::array<char_type, 4> true_literal = {{
static_cast<char_type
>(
't'),
static_cast<char_type
>(
'r'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'e')}};
8949 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8953 std::array<char_type, 5> false_literal = {{
static_cast<char_type
>(
'f'),
static_cast<char_type
>(
'a'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
's'),
static_cast<char_type
>(
'e')}};
8954 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8958 std::array<char_type, 4> null_literal = {{
static_cast<char_type
>(
'n'),
static_cast<char_type
>(
'u'),
static_cast<char_type
>(
'l'),
static_cast<char_type
>(
'l')}};
8959 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8964 return scan_string();
8978 return scan_number();
8984 return token_type::end_of_input;
8988 error_message =
"invalid literal";
8989 return token_type::parse_error;
8995 InputAdapterType ia;
8998 const bool ignore_comments =
false;
9004 bool next_unget =
false;
9010 std::vector<char_type> token_string {};
9013 string_t token_buffer {};
9016 const char* error_message =
"";
9019 number_integer_t value_integer = 0;
9020 number_unsigned_t value_unsigned = 0;
9021 number_float_t value_float = 0;
9024 const char_int_type decimal_point_char =
'.';
9063 decltype(std::declval<T&>().boolean(std::declval<bool>()));
9065template<
typename T,
typename Integer>
9067 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
9069template<
typename T,
typename Un
signed>
9071 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
9073template<
typename T,
typename Float,
typename String>
9075 std::declval<Float>(), std::declval<const String&>()));
9077template<
typename T,
typename String>
9079 decltype(std::declval<T&>().string(std::declval<String&>()));
9081template<
typename T,
typename Binary>
9083 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
9087 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
9089template<
typename T,
typename String>
9091 decltype(std::declval<T&>().key(std::declval<String&>()));
9098 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9103template<
typename T,
typename Exception>
9105 std::declval<std::size_t>(), std::declval<const std::string&>(),
9106 std::declval<const Exception&>()));
9108template<
typename SAX,
typename BasicJsonType>
9113 "BasicJsonType must be of type basic_json<...>");
9115 using number_integer_t =
typename BasicJsonType::number_integer_t;
9116 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9117 using number_float_t =
typename BasicJsonType::number_float_t;
9118 using string_t =
typename BasicJsonType::string_t;
9119 using binary_t =
typename BasicJsonType::binary_t;
9120 using exception_t =
typename BasicJsonType::exception;
9139template<
typename SAX,
typename BasicJsonType>
9144 "BasicJsonType must be of type basic_json<...>");
9146 using number_integer_t =
typename BasicJsonType::number_integer_t;
9147 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9148 using number_float_t =
typename BasicJsonType::number_float_t;
9149 using string_t =
typename BasicJsonType::string_t;
9150 using binary_t =
typename BasicJsonType::binary_t;
9151 using exception_t =
typename BasicJsonType::exception;
9155 "Missing/invalid function: bool null()");
9157 "Missing/invalid function: bool boolean(bool)");
9159 "Missing/invalid function: bool boolean(bool)");
9163 "Missing/invalid function: bool number_integer(number_integer_t)");
9167 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9169 number_float_t, string_t>
::value,
9170 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9173 "Missing/invalid function: bool string(string_t&)");
9176 "Missing/invalid function: bool binary(binary_t&)");
9178 "Missing/invalid function: bool start_object(std::size_t)");
9180 "Missing/invalid function: bool key(string_t&)");
9182 "Missing/invalid function: bool end_object()");
9184 "Missing/invalid function: bool start_array(std::size_t)");
9186 "Missing/invalid function: bool end_array()");
9189 "Missing/invalid function: bool parse_error(std::size_t, const "
9190 "std::string&, const exception&)");
9222static inline bool little_endianness(
int num = 1) noexcept
9224 return *
reinterpret_cast<char*
>(&num) == 1;
9234template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9237 using number_integer_t =
typename BasicJsonType::number_integer_t;
9238 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
9239 using number_float_t =
typename BasicJsonType::number_float_t;
9240 using string_t =
typename BasicJsonType::string_t;
9241 using binary_t =
typename BasicJsonType::binary_t;
9242 using json_sax_t = SAX;
9243 using char_type =
typename InputAdapterType::char_type;
9275 const
bool strict = true,
9279 bool result =
false;
9284 result = parse_bson_internal();
9288 result = parse_cbor_internal(
true, tag_handler);
9292 result = parse_msgpack_internal();
9297 result = parse_ubjson_internal();
9319 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read,
9320 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9336 bool parse_bson_internal()
9338 std::int32_t document_size{};
9351 return sax->end_object();
9361 bool get_bson_cstr(string_t& result)
9363 auto out = std::back_inserter(result);
9371 if (current == 0x00)
9375 *out++ =
static_cast<typename string_t::value_type
>(current);
9390 template<
typename NumberType>
9391 bool get_bson_string(
const NumberType len, string_t& result)
9395 auto last_token = get_token_string();
9397 exception_message(
input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
9400 return get_string(
input_format_t::bson, len -
static_cast<NumberType
>(1), result) && get() != char_traits<char_type>::eof();
9412 template<
typename NumberType>
9413 bool get_bson_binary(
const NumberType len, binary_t& result)
9417 auto last_token = get_token_string();
9419 exception_message(
input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
9423 std::uint8_t subtype{};
9425 result.set_subtype(subtype);
9440 bool parse_bson_element_internal(
const char_int_type element_type,
9441 const std::size_t element_type_parse_position)
9443 switch (element_type)
9448 return get_number<double, true>(
input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
9460 return parse_bson_internal();
9465 return parse_bson_array();
9477 return sax->boolean(get() != 0);
9487 std::int32_t
value{};
9493 std::int64_t
value{};
9499 std::array<char, 3> cr{{}};
9500 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9501 const std::string cr_str{cr.data()};
9502 return sax->parse_error(element_type_parse_position, cr_str,
9520 bool parse_bson_element_list(
const bool is_array)
9524 while (
auto element_type = get())
9531 const std::size_t element_type_parse_position = chars_read;
9537 if (!is_array && !sax->key(
key))
9542 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9558 bool parse_bson_array()
9560 std::int32_t document_size{};
9573 return sax->end_array();
9588 bool parse_cbor_internal(
const bool get_char,
9591 switch (get_char ? get() : current)
9594 case char_traits<char_type>::eof():
9622 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
9626 std::uint8_t number{};
9632 std::uint16_t number{};
9638 std::uint32_t number{};
9644 std::uint64_t number{};
9673 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9677 std::uint8_t number{};
9678 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9683 std::uint16_t number{};
9684 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9689 std::uint32_t number{};
9690 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1) - number);
9695 std::uint64_t number{};
9696 return get_number(
input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t
>(-1)
9697 -
static_cast<number_integer_t
>(number));
9732 return get_cbor_binary(b) && sax->binary(b);
9767 return get_cbor_string(s) && sax->string(s);
9795 return get_cbor_array(
9801 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9806 std::uint16_t len{};
9807 return get_number(
input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t
>(len), tag_handler);
9812 std::uint32_t len{};
9818 std::uint64_t len{};
9823 return get_cbor_array(
static_cast<std::size_t
>(-1), tag_handler);
9855 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9860 std::uint16_t len{};
9861 return get_number(
input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t
>(len), tag_handler);
9866 std::uint32_t len{};
9872 std::uint64_t len{};
9877 return get_cbor_object(
static_cast<std::size_t
>(-1), tag_handler);
9899 switch (tag_handler)
9903 auto last_token = get_token_string();
9915 std::uint8_t subtype_to_ignore{};
9921 std::uint16_t subtype_to_ignore{};
9927 std::uint32_t subtype_to_ignore{};
9933 std::uint64_t subtype_to_ignore{};
9940 return parse_cbor_internal(
true, tag_handler);
9951 std::uint8_t subtype{};
9958 std::uint16_t subtype{};
9965 std::uint32_t subtype{};
9972 std::uint64_t subtype{};
9978 return parse_cbor_internal(
true, tag_handler);
9981 return get_cbor_binary(b) && sax->binary(b);
9991 return sax->boolean(
false);
9994 return sax->boolean(
true);
10001 const auto byte1_raw = get();
10006 const auto byte2_raw = get();
10012 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
10013 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
10023 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
10024 const double val = [&half]
10026 const int exp = (half >> 10u) & 0x1Fu;
10027 const unsigned int mant = half & 0x3FFu;
10033 return std::ldexp(mant, -24);
10036 ? std::numeric_limits<double>::infinity()
10037 :
std::numeric_limits<double>::quiet_NaN();
10039 return std::ldexp(mant + 1024, exp - 25);
10042 return sax->number_float((half & 0x8000u) != 0
10043 ?
static_cast<number_float_t
>(-val)
10044 :
static_cast<number_float_t
>(val),
"");
10050 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10056 return get_number(
input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10061 auto last_token = get_token_string();
10079 bool get_cbor_string(string_t& result)
10119 std::uint8_t len{};
10125 std::uint16_t len{};
10131 std::uint32_t len{};
10137 std::uint64_t len{};
10143 while (get() != 0xFF)
10146 if (!get_cbor_string(chunk))
10150 result.append(chunk);
10157 auto last_token = get_token_string();
10159 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10175 bool get_cbor_binary(binary_t& result)
10215 std::uint8_t len{};
10222 std::uint16_t len{};
10229 std::uint32_t len{};
10236 std::uint64_t len{};
10243 while (get() != 0xFF)
10246 if (!get_cbor_binary(chunk))
10250 result.insert(result.end(), chunk.begin(), chunk.end());
10257 auto last_token = get_token_string();
10259 exception_message(
input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10270 bool get_cbor_array(
const std::size_t len,
10278 if (len !=
static_cast<std::size_t
>(-1))
10280 for (std::size_t i = 0; i < len; ++i)
10290 while (get() != 0xFF)
10299 return sax->end_array();
10308 bool get_cbor_object(
const std::size_t len,
10319 if (len !=
static_cast<std::size_t
>(-1))
10321 for (std::size_t i = 0; i < len; ++i)
10338 while (get() != 0xFF)
10354 return sax->end_object();
10364 bool parse_msgpack_internal()
10369 case char_traits<char_type>::eof():
10501 return sax->number_unsigned(
static_cast<number_unsigned_t
>(current));
10579 return get_msgpack_string(s) && sax->string(s);
10583 return sax->null();
10586 return sax->boolean(
false);
10589 return sax->boolean(
true);
10604 return get_msgpack_binary(b) && sax->binary(b);
10610 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10616 return get_number(
input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
10621 std::uint8_t number{};
10627 std::uint16_t number{};
10633 std::uint32_t number{};
10639 std::uint64_t number{};
10645 std::int8_t number{};
10651 std::int16_t number{};
10657 std::int32_t number{};
10663 std::int64_t number{};
10669 std::uint16_t len{};
10675 std::uint32_t len{};
10681 std::uint16_t len{};
10687 std::uint32_t len{};
10724 return sax->number_integer(
static_cast<std::int8_t
>(current));
10728 auto last_token = get_token_string();
10745 bool get_msgpack_string(string_t& result)
10793 std::uint8_t len{};
10799 std::uint16_t len{};
10805 std::uint32_t len{};
10811 auto last_token = get_token_string();
10813 exception_message(
input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10828 bool get_msgpack_binary(binary_t& result)
10831 auto assign_and_return_true = [&result](std::int8_t subtype)
10833 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10841 std::uint8_t len{};
10848 std::uint16_t len{};
10855 std::uint32_t len{};
10862 std::uint8_t len{};
10863 std::int8_t subtype{};
10867 assign_and_return_true(subtype);
10872 std::uint16_t len{};
10873 std::int8_t subtype{};
10877 assign_and_return_true(subtype);
10882 std::uint32_t len{};
10883 std::int8_t subtype{};
10887 assign_and_return_true(subtype);
10892 std::int8_t subtype{};
10895 assign_and_return_true(subtype);
10900 std::int8_t subtype{};
10903 assign_and_return_true(subtype);
10908 std::int8_t subtype{};
10911 assign_and_return_true(subtype);
10916 std::int8_t subtype{};
10919 assign_and_return_true(subtype);
10924 std::int8_t subtype{};
10927 assign_and_return_true(subtype);
10939 bool get_msgpack_array(
const std::size_t len)
10946 for (std::size_t i = 0; i < len; ++i)
10954 return sax->end_array();
10961 bool get_msgpack_object(
const std::size_t len)
10969 for (std::size_t i = 0; i < len; ++i)
10984 return sax->end_object();
10998 bool parse_ubjson_internal(
const bool get_char =
true)
11000 return get_ubjson_value(get_char ? get_ignore_noop() : current);
11017 bool get_ubjson_string(string_t& result,
const bool get_char =
true)
11033 std::uint8_t len{};
11034 return get_number(input_format, len) && get_string(input_format, len, result);
11040 return get_number(input_format, len) && get_string(input_format, len, result);
11045 std::int16_t len{};
11046 return get_number(input_format, len) && get_string(input_format, len, result);
11051 std::int32_t len{};
11052 return get_number(input_format, len) && get_string(input_format, len, result);
11057 std::int64_t len{};
11058 return get_number(input_format, len) && get_string(input_format, len, result);
11067 std::uint16_t len{};
11068 return get_number(input_format, len) && get_string(input_format, len, result);
11077 std::uint32_t len{};
11078 return get_number(input_format, len) && get_string(input_format, len, result);
11087 std::uint64_t len{};
11088 return get_number(input_format, len) && get_string(input_format, len, result);
11094 auto last_token = get_token_string();
11095 std::string message;
11099 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11103 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11105 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11112 bool get_ubjson_ndarray_size(std::vector<size_t>& dim)
11114 std::pair<std::size_t, char_int_type> size_and_type;
11116 bool no_ndarray =
true;
11123 if (size_and_type.first != npos)
11125 if (size_and_type.second != 0)
11127 if (size_and_type.second !=
'N')
11129 for (std::size_t i = 0; i < size_and_type.first; ++i)
11135 dim.push_back(dimlen);
11141 for (std::size_t i = 0; i < size_and_type.first; ++i)
11147 dim.push_back(dimlen);
11153 while (current !=
']')
11159 dim.push_back(dimlen);
11177 bool get_ubjson_size_value(std::size_t& result,
bool& is_ndarray, char_int_type prefix = 0)
11181 prefix = get_ignore_noop();
11188 std::uint8_t number{};
11193 result =
static_cast<std::size_t
>(number);
11199 std::int8_t number{};
11206 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11207 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11209 result =
static_cast<std::size_t
>(number);
11215 std::int16_t number{};
11222 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11223 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11225 result =
static_cast<std::size_t
>(number);
11231 std::int32_t number{};
11238 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11239 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11241 result =
static_cast<std::size_t
>(number);
11247 std::int64_t number{};
11254 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read,
11255 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11260 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11262 result =
static_cast<std::size_t
>(number);
11272 std::uint16_t number{};
11277 result =
static_cast<std::size_t
>(number);
11287 std::uint32_t number{};
11302 std::uint64_t number{};
11310 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11324 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11326 std::vector<size_t> dim;
11331 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11333 result = dim.at(dim.size() - 1);
11347 string_t
key =
"_ArraySize_";
11356 if (result == 0 || result == npos)
11358 return sax->parse_error(chars_read, get_token_string(),
out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
11366 return sax->end_array();
11375 auto last_token = get_token_string();
11376 std::string message;
11380 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11384 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11386 return sax->parse_error(chars_read, last_token,
parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11400 bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result,
bool inside_ndarray =
false)
11402 result.first = npos;
11404 bool is_ndarray =
false;
11408 if (current ==
'$')
11410 result.second = get();
11412 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11414 auto last_token = get_token_string();
11416 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11431 auto last_token = get_token_string();
11433 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11436 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11439 if (inside_ndarray)
11441 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11442 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11444 result.second |= (1 << 8);
11449 if (current ==
'#')
11451 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11454 return sax->parse_error(chars_read, get_token_string(),
parse_error::create(112, chars_read,
11455 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11467 bool get_ubjson_value(
const char_int_type prefix)
11471 case char_traits<char_type>::eof():
11472 return unexpect_eof(input_format,
"value");
11475 return sax->boolean(
true);
11477 return sax->boolean(
false);
11480 return sax->null();
11484 std::uint8_t number{};
11485 return get_number(input_format, number) && sax->number_unsigned(number);
11490 std::int8_t number{};
11491 return get_number(input_format, number) && sax->number_integer(number);
11496 std::int16_t number{};
11497 return get_number(input_format, number) && sax->number_integer(number);
11502 std::int32_t number{};
11503 return get_number(input_format, number) && sax->number_integer(number);
11508 std::int64_t number{};
11509 return get_number(input_format, number) && sax->number_integer(number);
11518 std::uint16_t number{};
11519 return get_number(input_format, number) && sax->number_unsigned(number);
11528 std::uint32_t number{};
11529 return get_number(input_format, number) && sax->number_unsigned(number);
11538 std::uint64_t number{};
11539 return get_number(input_format, number) && sax->number_unsigned(number);
11548 const auto byte1_raw = get();
11553 const auto byte2_raw = get();
11559 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11560 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11570 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11571 const double val = [&half]
11573 const int exp = (half >> 10u) & 0x1Fu;
11574 const unsigned int mant = half & 0x3FFu;
11580 return std::ldexp(mant, -24);
11583 ? std::numeric_limits<double>::infinity()
11584 :
std::numeric_limits<double>::quiet_NaN();
11586 return std::ldexp(mant + 1024, exp - 25);
11589 return sax->number_float((half & 0x8000u) != 0
11590 ?
static_cast<number_float_t
>(-val)
11591 :
static_cast<number_float_t
>(val),
"");
11597 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11603 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t
>(number),
"");
11608 return get_ubjson_high_precision_number();
11620 auto last_token = get_token_string();
11622 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11624 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11625 return sax->string(s);
11631 return get_ubjson_string(s) && sax->string(s);
11635 return get_ubjson_array();
11638 return get_ubjson_object();
11643 auto last_token = get_token_string();
11644 return sax->parse_error(chars_read, last_token,
parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11650 bool get_ubjson_array()
11652 std::pair<std::size_t, char_int_type> size_and_type;
11661 if (input_format ==
input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11663 size_and_type.second &= ~(
static_cast<char_int_type
>(1) << 8);
11664 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p, char_int_type t)
11666 return p.first < t;
11668 string_t
key =
"_ArrayType_";
11671 auto last_token = get_token_string();
11673 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11676 string_t type = it->second;
11682 if (size_and_type.second ==
'C')
11684 size_and_type.second =
'U';
11687 key =
"_ArrayData_";
11693 for (std::size_t i = 0; i < size_and_type.first; ++i)
11701 return (sax->end_array() && sax->end_object());
11704 if (size_and_type.first != npos)
11711 if (size_and_type.second != 0)
11713 if (size_and_type.second !=
'N')
11715 for (std::size_t i = 0; i < size_and_type.first; ++i)
11726 for (std::size_t i = 0; i < size_and_type.first; ++i)
11742 while (current !=
']')
11752 return sax->end_array();
11758 bool get_ubjson_object()
11760 std::pair<std::size_t, char_int_type> size_and_type;
11767 if (input_format ==
input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11769 auto last_token = get_token_string();
11771 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11775 if (size_and_type.first != npos)
11782 if (size_and_type.second != 0)
11784 for (std::size_t i = 0; i < size_and_type.first; ++i)
11799 for (std::size_t i = 0; i < size_and_type.first; ++i)
11820 while (current !=
'}')
11835 return sax->end_object();
11841 bool get_ubjson_high_precision_number()
11844 std::size_t size{};
11845 bool no_ndarray =
true;
11846 auto res = get_ubjson_size_value(size, no_ndarray);
11853 std::vector<char> number_vector;
11854 for (std::size_t i = 0; i < size; ++i)
11861 number_vector.push_back(
static_cast<char>(current));
11867 const auto result_number = number_lexer.scan();
11868 const auto number_string = number_lexer.get_token_string();
11869 const auto result_remainder = number_lexer.scan();
11876 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11879 switch (result_number)
11881 case token_type::value_integer:
11882 return sax->number_integer(number_lexer.get_number_integer());
11883 case token_type::value_unsigned:
11884 return sax->number_unsigned(number_lexer.get_number_unsigned());
11885 case token_type::value_float:
11886 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11887 case token_type::uninitialized:
11888 case token_type::literal_true:
11889 case token_type::literal_false:
11890 case token_type::literal_null:
11891 case token_type::value_string:
11892 case token_type::begin_array:
11893 case token_type::begin_object:
11894 case token_type::end_array:
11895 case token_type::end_object:
11896 case token_type::name_separator:
11897 case token_type::value_separator:
11898 case token_type::parse_error:
11899 case token_type::end_of_input:
11900 case token_type::literal_or_value:
11903 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11920 char_int_type get()
11923 return current = ia.get_character();
11929 char_int_type get_ignore_noop()
11935 while (current ==
'N');
11955 template<
typename NumberType,
bool InputIsLittleEndian = false>
11956 bool get_number(
const input_format_t format, NumberType& result)
11959 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11960 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
11971 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11975 vec[i] =
static_cast<std::uint8_t
>(current);
11980 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11998 template<
typename NumberType>
12000 const NumberType len,
12003 bool success =
true;
12004 for (NumberType i = 0; i < len; i++)
12012 result.push_back(
static_cast<typename string_t::value_type
>(current));
12031 template<
typename NumberType>
12033 const NumberType len,
12036 bool success =
true;
12037 for (NumberType i = 0; i < len; i++)
12045 result.push_back(
static_cast<std::uint8_t
>(current));
12056 bool unexpect_eof(const
input_format_t format, const
char* context)
const
12060 return sax->parse_error(chars_read,
"<end of file>",
12061 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
12069 std::string get_token_string()
const
12071 std::array<char, 3> cr{{}};
12072 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
12073 return std::string{cr.data()};
12083 const std::string&
detail,
12084 const std::string& context)
const
12086 std::string error_msg =
"syntax error while parsing ";
12091 error_msg +=
"CBOR";
12095 error_msg +=
"MessagePack";
12099 error_msg +=
"UBJSON";
12103 error_msg +=
"BSON";
12107 error_msg +=
"BJData";
12122 InputAdapterType ia;
12125 char_int_type current = char_traits<char_type>::eof();
12128 std::size_t chars_read = 0;
12131 const bool is_little_endian = little_endianness();
12137 json_sax_t* sax =
nullptr;
12140#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12141 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12143#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12144 make_array<bjd_type>( \
12145 bjd_type{'C', "char"}, \
12146 bjd_type{'D', "double"}, \
12147 bjd_type{'I', "int16"}, \
12148 bjd_type{'L', "int64"}, \
12149 bjd_type{'M', "uint64"}, \
12150 bjd_type{'U', "uint8"}, \
12151 bjd_type{'d', "single"}, \
12152 bjd_type{'i', "int8"}, \
12153 bjd_type{'l', "int32"}, \
12154 bjd_type{'m', "uint32"}, \
12155 bjd_type{'u', "uint16"})
12163 using bjd_type = std::pair<char_int_type, string_t>;
12168#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12169#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12172#ifndef JSON_HAS_CPP_17
12173 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12174 constexpr std::size_t binary_reader<BasicJsonType, InputAdapterType, SAX>::npos;
12197#include <functional>
12242template<
typename BasicJsonType>
12244 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
12251template<
typename BasicJsonType,
typename InputAdapterType>
12254 using number_integer_t =
typename BasicJsonType::number_integer_t;
12255 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
12256 using number_float_t =
typename BasicJsonType::number_float_t;
12257 using string_t =
typename BasicJsonType::string_t;
12265 const bool allow_exceptions_ =
true,
12266 const bool skip_comments =
false)
12268 , m_lexer(
std::move(adapter), skip_comments)
12269 , allow_exceptions(allow_exceptions_)
12290 sax_parse_internal(&sdp);
12293 if (
strict && (get_token() != token_type::end_of_input))
12298 exception_message(token_type::end_of_input,
"value"),
nullptr));
12310 if (result.is_discarded())
12318 sax_parse_internal(&sdp);
12321 if (
strict && (get_token() != token_type::end_of_input))
12336 result.assert_invariant();
12351 template<
typename SAX>
12356 const bool result = sax_parse_internal(sax);
12359 if (result &&
strict && (get_token() != token_type::end_of_input))
12370 template<
typename SAX>
12372 bool sax_parse_internal(SAX* sax)
12376 std::vector<bool> states;
12378 bool skip_to_state_evaluation =
false;
12382 if (!skip_to_state_evaluation)
12385 switch (last_token)
12387 case token_type::begin_object:
12395 if (get_token() == token_type::end_object)
12425 states.push_back(
false);
12432 case token_type::begin_array:
12440 if (get_token() == token_type::end_array)
12450 states.push_back(
true);
12456 case token_type::value_float:
12475 case token_type::literal_false:
12484 case token_type::literal_null:
12493 case token_type::literal_true:
12502 case token_type::value_integer:
12511 case token_type::value_string:
12520 case token_type::value_unsigned:
12529 case token_type::parse_error:
12536 case token_type::end_of_input:
12543 "attempting to parse an empty input; check that your input string or stream contains the expected JSON",
nullptr));
12550 case token_type::uninitialized:
12551 case token_type::end_array:
12552 case token_type::end_object:
12553 case token_type::name_separator:
12554 case token_type::value_separator:
12555 case token_type::literal_or_value:
12566 skip_to_state_evaluation =
false;
12570 if (states.empty())
12579 if (get_token() == token_type::value_separator)
12600 skip_to_state_evaluation =
true;
12612 if (get_token() == token_type::value_separator)
12654 skip_to_state_evaluation =
true;
12665 token_type get_token()
12667 return last_token = m_lexer.
scan();
12670 std::string exception_message(
const token_type expected,
const std::string& context)
12672 std::string error_msg =
"syntax error ";
12674 if (!context.empty())
12676 error_msg +=
concat(
"while parsing ", context,
' ');
12681 if (last_token == token_type::parse_error)
12691 if (expected != token_type::uninitialized)
12703 token_type last_token = token_type::uninitialized;
12707 const bool allow_exceptions =
true;
12759 using difference_type = std::ptrdiff_t;
12760 static constexpr difference_type begin_value = 0;
12761 static constexpr difference_type end_value = begin_value + 1;
12765 difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
12776 m_it = begin_value;
12788 return m_it == begin_value;
12794 return m_it == end_value;
12799 return lhs.m_it == rhs.m_it;
12804 return lhs.m_it < rhs.m_it;
12809 auto result = *
this;
12816 return lhs.m_it - rhs.m_it;
12827 auto result = *
this;
12840 auto result = *
this;
12897#include <type_traits>
12938template<
typename BasicJsonType>
12945 friend BasicJsonType;
12949 using object_t =
typename BasicJsonType::object_t;
12950 using array_t =
typename BasicJsonType::array_t;
12953 "iter_impl only accepts (const) basic_json");
12955 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12956 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
12957 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12972 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12973 typename BasicJsonType::const_pointer,
12974 typename BasicJsonType::pointer>::type;
12977 typename std::conditional<std::is_const<BasicJsonType>::value,
12978 typename BasicJsonType::const_reference,
12979 typename BasicJsonType::reference>::type;
12996 switch (m_object->m_data.m_type)
13000 m_it.object_iterator =
typename object_t::iterator();
13006 m_it.array_iterator =
typename array_t::iterator();
13043 : m_object(other.m_object),
m_it(other.m_it)
13054 if (&other !=
this)
13056 m_object = other.m_object;
13068 : m_object(other.m_object),
m_it(other.m_it)
13079 m_object = other.m_object;
13089 void set_begin() noexcept
13093 switch (m_object->m_data.m_type)
13097 m_it.object_iterator = m_object->m_data.m_value.object->begin();
13103 m_it.array_iterator = m_object->m_data.m_value.array->begin();
13110 m_it.primitive_iterator.set_end();
13123 m_it.primitive_iterator.set_begin();
13137 switch (m_object->m_data.m_type)
13141 m_it.object_iterator = m_object->m_data.m_value.object->end();
13147 m_it.array_iterator = m_object->m_data.m_value.array->end();
13161 m_it.primitive_iterator.set_end();
13176 switch (m_object->m_data.m_type)
13180 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13181 return m_it.object_iterator->second;
13186 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13187 return *
m_it.array_iterator;
13220 switch (m_object->m_data.m_type)
13224 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
13225 return &(
m_it.object_iterator->second);
13230 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
13231 return &*
m_it.array_iterator;
13260 auto result = *
this;
13273 switch (m_object->m_data.m_type)
13277 std::advance(
m_it.object_iterator, 1);
13283 std::advance(
m_it.array_iterator, 1);
13297 ++
m_it.primitive_iterator;
13311 auto result = *
this;
13324 switch (m_object->m_data.m_type)
13328 std::advance(
m_it.object_iterator, -1);
13334 std::advance(
m_it.array_iterator, -1);
13348 --
m_it.primitive_iterator;
13360 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13371 switch (m_object->m_data.m_type)
13374 return (
m_it.object_iterator == other.m_it.object_iterator);
13377 return (
m_it.array_iterator == other.m_it.array_iterator);
13388 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
13396 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13416 switch (m_object->m_data.m_type)
13422 return (
m_it.array_iterator < other.
m_it.array_iterator);
13433 return (
m_it.primitive_iterator < other.
m_it.primitive_iterator);
13443 return !other.operator < (*this);
13472 switch (m_object->m_data.m_type)
13479 std::advance(
m_it.array_iterator, i);
13493 m_it.primitive_iterator += i;
13516 auto result = *
this;
13538 auto result = *
this;
13551 switch (m_object->m_data.m_type)
13557 return m_it.array_iterator - other.
m_it.array_iterator;
13568 return m_it.primitive_iterator - other.
m_it.primitive_iterator;
13580 switch (m_object->m_data.m_type)
13586 return *std::next(
m_it.array_iterator, n);
13614 const typename object_t::key_type&
key()
const
13620 return m_it.object_iterator->first;
13691template<
typename Base>
13765 auto it = --this->base();
13772 auto it = --this->base();
13773 return it.operator * ();
13793#include <type_traits>
13816 std::is_same<T, void>::value,
13835#include <algorithm>
13863template<
typename RefStringType>
13873 template<
typename T>
13874 struct string_t_helper
13882 using type = StringType;
13887 using string_t =
typename string_t_helper<RefStringType>::type;
13892 : reference_tokens(split(s))
13899 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13903 return detail::concat(a,
'/', detail::escape(b));
13929 reference_tokens.insert(reference_tokens.end(),
13930 ptr.reference_tokens.begin(),
13931 ptr.reference_tokens.end());
13947 return *
this /= std::to_string(array_idx);
13995 reference_tokens.pop_back();
14007 return reference_tokens.back();
14014 reference_tokens.push_back(token);
14021 reference_tokens.push_back(std::move(token));
14028 return reference_tokens.empty();
14042 template<
typename BasicJsonType>
14043 static typename BasicJsonType::size_type array_index(
const string_t& s)
14045 using size_type =
typename BasicJsonType::size_type;
14059 const char* p = s.c_str();
14060 char* p_end =
nullptr;
14062 const unsigned long long res = std::strtoull(p, &p_end, 10);
14072 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
14077 return static_cast<size_type
>(res);
14089 result.reference_tokens = {reference_tokens[0]};
14102 template<
typename BasicJsonType>
14103 BasicJsonType& get_and_create(BasicJsonType& j)
const
14109 for (
const auto& reference_token : reference_tokens)
14111 switch (result->type())
14115 if (reference_token ==
"0")
14118 result = &result->operator[](0);
14123 result = &result->operator[](reference_token);
14131 result = &result->operator[](reference_token);
14138 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14182 template<
typename BasicJsonType>
14183 BasicJsonType& get_unchecked(BasicJsonType* ptr)
const
14185 for (
const auto& reference_token : reference_tokens)
14188 if (ptr->is_null())
14192 std::all_of(reference_token.begin(), reference_token.end(),
14193 [](
const unsigned char x)
14195 return std::isdigit(x);
14199 *ptr = (nums || reference_token ==
"-")
14204 switch (ptr->type())
14209 ptr = &ptr->operator[](reference_token);
14215 if (reference_token ==
"-")
14218 ptr = &ptr->operator[](ptr->m_data.m_value.array->size());
14223 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14250 template<
typename BasicJsonType>
14251 BasicJsonType& get_checked(BasicJsonType* ptr)
const
14253 for (
const auto& reference_token : reference_tokens)
14255 switch (ptr->type())
14260 ptr = &ptr->at(reference_token);
14270 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14271 ") is out of range"), ptr));
14275 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14308 template<
typename BasicJsonType>
14309 const BasicJsonType& get_unchecked(
const BasicJsonType* ptr)
const
14311 for (
const auto& reference_token : reference_tokens)
14313 switch (ptr->type())
14318 ptr = &ptr->operator[](reference_token);
14331 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14357 template<
typename BasicJsonType>
14358 const BasicJsonType& get_checked(
const BasicJsonType* ptr)
const
14360 for (
const auto& reference_token : reference_tokens)
14362 switch (ptr->type())
14367 ptr = &ptr->at(reference_token);
14377 "array index '-' (", std::to_string(ptr->m_data.m_value.array->size()),
14378 ") is out of range"), ptr));
14382 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14406 template<
typename BasicJsonType>
14407 bool contains(
const BasicJsonType* ptr)
const
14409 for (
const auto& reference_token : reference_tokens)
14411 switch (ptr->type())
14415 if (!ptr->contains(reference_token))
14421 ptr = &ptr->operator[](reference_token);
14432 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14444 for (std::size_t i = 1; i < reference_token.size(); i++)
14454 const auto idx = array_index<BasicJsonType>(reference_token);
14455 if (idx >= ptr->size())
14461 ptr = &ptr->operator[](idx);
14495 static std::vector<string_t> split(
const string_t& reference_string)
14497 std::vector<string_t> result;
14500 if (reference_string.empty())
14516 std::size_t slash = reference_string.find_first_of(
'/', 1),
14523 start = (slash == string_t::npos) ? 0 : slash + 1,
14525 slash = reference_string.find_first_of(
'/', start))
14529 auto reference_token = reference_string.substr(start, slash - start);
14532 for (std::size_t pos = reference_token.find_first_of(
'~');
14533 pos != string_t::npos;
14534 pos = reference_token.find_first_of(
'~', pos + 1))
14540 (reference_token[pos + 1] !=
'0' &&
14541 reference_token[pos + 1] !=
'1')))
14548 detail::unescape(reference_token);
14549 result.push_back(reference_token);
14563 template<
typename BasicJsonType>
14564 static void flatten(
const string_t& reference_string,
14565 const BasicJsonType& value,
14566 BasicJsonType& result)
14568 switch (
value.type())
14572 if (
value.m_data.m_value.array->empty())
14575 result[reference_string] =
nullptr;
14580 for (std::size_t i = 0; i <
value.m_data.m_value.array->size(); ++i)
14582 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
14583 value.m_data.m_value.array->operator[](i), result);
14591 if (
value.m_data.m_value.object->empty())
14594 result[reference_string] =
nullptr;
14599 for (
const auto& element : *
value.m_data.m_value.object)
14618 result[reference_string] =
value;
14634 template<
typename BasicJsonType>
14635 static BasicJsonType
14636 unflatten(
const BasicJsonType& value)
14643 BasicJsonType result;
14646 for (
const auto& element : *
value.m_data.m_value.object)
14657 json_pointer(element.first).get_and_create(result) = element.second;
14667 result.reference_tokens = reference_tokens;
14674 result.reference_tokens = std::move(reference_tokens);
14679#if JSON_HAS_THREE_WAY_COMPARISON
14682 template<
typename RefStringTypeRhs>
14685 return reference_tokens == rhs.reference_tokens;
14697 template<
typename RefStringTypeRhs>
14700 return reference_tokens <=> rhs.reference_tokens;
14705 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14712 template<
typename RefStringTypeLhs,
typename StringType>
14715 const StringType& rhs);
14719 template<
typename RefStringTypeRhs,
typename StringType>
14721 friend bool operator==(
const StringType& lhs,
14726 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14733 template<
typename RefStringTypeLhs,
typename StringType>
14736 const StringType& rhs);
14740 template<
typename RefStringTypeRhs,
typename StringType>
14742 friend bool operator!=(
const StringType& lhs,
14746 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14754 std::vector<string_t> reference_tokens;
14757#if !JSON_HAS_THREE_WAY_COMPARISON
14759template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14763 return lhs.reference_tokens == rhs.reference_tokens;
14766template<
typename RefStringTypeLhs,
14770 const StringType& rhs)
14775template<
typename RefStringTypeRhs,
14778inline
bool operator==(const StringType& lhs,
14784template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14788 return !(lhs == rhs);
14791template<
typename RefStringTypeLhs,
14795 const StringType& rhs)
14797 return !(lhs == rhs);
14800template<
typename RefStringTypeRhs,
14803inline
bool operator!=(const StringType& lhs,
14806 return !(lhs == rhs);
14809template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14813 return lhs.reference_tokens < rhs.reference_tokens;
14830#include <initializer_list>
14842template<
typename BasicJsonType>
14853 : value_ref(&
value)
14857 : owned_value(init)
14864 : owned_value(
std::forward<Args>(args)...)
14876 if (value_ref ==
nullptr)
14878 return std::move(owned_value);
14885 return value_ref ? *value_ref : owned_value;
14922#include <algorithm>
14948#include <algorithm>
14982template<typename CharType>
14986template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
15000 void write_characters(const CharType* s,
std::
size_t length)
override
15002 v.insert(v.end(), s, s + length);
15006 std::vector<CharType, AllocatorType>& v;
15011template<
typename CharType>
15025 void write_characters(const CharType* s,
std::
size_t length)
override
15027 stream.write(s,
static_cast<std::streamsize
>(length));
15031 std::basic_ostream<CharType>& stream;
15036template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15050 void write_characters(const CharType* s,
std::
size_t length)
override
15052 str.append(s, length);
15059template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
15063 template<
typename AllocatorType = std::allocator<CharType>>
15101template<
typename BasicJsonType,
typename CharType>
15104 using string_t =
typename BasicJsonType::string_t;
15105 using binary_t =
typename BasicJsonType::binary_t;
15106 using number_float_t =
typename BasicJsonType::number_float_t;
15127 case value_t::object:
15129 write_bson_object(*j.m_data.m_value.object);
15133 case value_t::null:
15134 case value_t::array:
15135 case value_t::string:
15136 case value_t::boolean:
15137 case value_t::number_integer:
15138 case value_t::number_unsigned:
15139 case value_t::number_float:
15140 case value_t::binary:
15141 case value_t::discarded:
15144 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15156 case value_t::null:
15158 oa->write_character(to_char_type(0xF6));
15162 case value_t::boolean:
15164 oa->write_character(j.m_data.m_value.boolean
15165 ? to_char_type(0xF5)
15166 : to_char_type(0xF4));
15170 case value_t::number_integer:
15172 if (j.m_data.m_value.number_integer >= 0)
15177 if (j.m_data.m_value.number_integer <= 0x17)
15179 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15181 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15183 oa->write_character(to_char_type(0x18));
15184 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15186 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15188 oa->write_character(to_char_type(0x19));
15189 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15191 else if (j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15193 oa->write_character(to_char_type(0x1A));
15194 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15198 oa->write_character(to_char_type(0x1B));
15199 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15206 const auto positive_number = -1 - j.m_data.m_value.number_integer;
15207 if (j.m_data.m_value.number_integer >= -24)
15209 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15211 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15213 oa->write_character(to_char_type(0x38));
15214 write_number(
static_cast<std::uint8_t
>(positive_number));
15216 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15218 oa->write_character(to_char_type(0x39));
15219 write_number(
static_cast<std::uint16_t
>(positive_number));
15221 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15223 oa->write_character(to_char_type(0x3A));
15224 write_number(
static_cast<std::uint32_t
>(positive_number));
15228 oa->write_character(to_char_type(0x3B));
15229 write_number(
static_cast<std::uint64_t
>(positive_number));
15235 case value_t::number_unsigned:
15237 if (j.m_data.m_value.number_unsigned <= 0x17)
15239 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15241 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15243 oa->write_character(to_char_type(0x18));
15244 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_unsigned));
15246 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15248 oa->write_character(to_char_type(0x19));
15249 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_unsigned));
15251 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15253 oa->write_character(to_char_type(0x1A));
15254 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_unsigned));
15258 oa->write_character(to_char_type(0x1B));
15259 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_unsigned));
15264 case value_t::number_float:
15266 if (std::isnan(j.m_data.m_value.number_float))
15269 oa->write_character(to_char_type(0xF9));
15270 oa->write_character(to_char_type(0x7E));
15271 oa->write_character(to_char_type(0x00));
15273 else if (std::isinf(j.m_data.m_value.number_float))
15276 oa->write_character(to_char_type(0xf9));
15277 oa->write_character(j.m_data.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15278 oa->write_character(to_char_type(0x00));
15287 case value_t::string:
15290 const auto N = j.m_data.m_value.string->size();
15293 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15295 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15297 oa->write_character(to_char_type(0x78));
15298 write_number(
static_cast<std::uint8_t
>(N));
15300 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15302 oa->write_character(to_char_type(0x79));
15303 write_number(
static_cast<std::uint16_t
>(N));
15305 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15307 oa->write_character(to_char_type(0x7A));
15308 write_number(
static_cast<std::uint32_t
>(N));
15311 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15313 oa->write_character(to_char_type(0x7B));
15314 write_number(
static_cast<std::uint64_t
>(N));
15319 oa->write_characters(
15320 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15321 j.m_data.m_value.string->size());
15325 case value_t::array:
15328 const auto N = j.m_data.m_value.array->size();
15331 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15333 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15335 oa->write_character(to_char_type(0x98));
15336 write_number(
static_cast<std::uint8_t
>(N));
15338 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15340 oa->write_character(to_char_type(0x99));
15341 write_number(
static_cast<std::uint16_t
>(N));
15343 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15345 oa->write_character(to_char_type(0x9A));
15346 write_number(
static_cast<std::uint32_t
>(N));
15349 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15351 oa->write_character(to_char_type(0x9B));
15352 write_number(
static_cast<std::uint64_t
>(N));
15357 for (
const auto& el : *j.m_data.m_value.array)
15364 case value_t::binary:
15366 if (j.m_data.m_value.binary->has_subtype())
15368 if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15370 write_number(
static_cast<std::uint8_t
>(0xd8));
15371 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.binary->subtype()));
15373 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15375 write_number(
static_cast<std::uint8_t
>(0xd9));
15376 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.binary->subtype()));
15378 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15380 write_number(
static_cast<std::uint8_t
>(0xda));
15381 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.binary->subtype()));
15383 else if (j.m_data.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15385 write_number(
static_cast<std::uint8_t
>(0xdb));
15386 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.binary->subtype()));
15391 const auto N = j.m_data.m_value.binary->size();
15394 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15396 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15398 oa->write_character(to_char_type(0x58));
15399 write_number(
static_cast<std::uint8_t
>(N));
15401 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15403 oa->write_character(to_char_type(0x59));
15404 write_number(
static_cast<std::uint16_t
>(N));
15406 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15408 oa->write_character(to_char_type(0x5A));
15409 write_number(
static_cast<std::uint32_t
>(N));
15412 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15414 oa->write_character(to_char_type(0x5B));
15415 write_number(
static_cast<std::uint64_t
>(N));
15420 oa->write_characters(
15421 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15427 case value_t::object:
15430 const auto N = j.m_data.m_value.object->size();
15433 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15435 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15437 oa->write_character(to_char_type(0xB8));
15438 write_number(
static_cast<std::uint8_t
>(N));
15440 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15442 oa->write_character(to_char_type(0xB9));
15443 write_number(
static_cast<std::uint16_t
>(N));
15445 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15447 oa->write_character(to_char_type(0xBA));
15448 write_number(
static_cast<std::uint32_t
>(N));
15451 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15453 oa->write_character(to_char_type(0xBB));
15454 write_number(
static_cast<std::uint64_t
>(N));
15459 for (
const auto& el : *j.m_data.m_value.object)
15461 write_cbor(el.first);
15462 write_cbor(el.second);
15467 case value_t::discarded:
15480 case value_t::null:
15482 oa->write_character(to_char_type(0xC0));
15486 case value_t::boolean:
15488 oa->write_character(j.m_data.m_value.boolean
15489 ? to_char_type(0xC3)
15490 : to_char_type(0xC2));
15494 case value_t::number_integer:
15496 if (j.m_data.m_value.number_integer >= 0)
15501 if (j.m_data.m_value.number_unsigned < 128)
15504 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15506 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15509 oa->write_character(to_char_type(0xCC));
15510 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15512 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15515 oa->write_character(to_char_type(0xCD));
15516 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15518 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15521 oa->write_character(to_char_type(0xCE));
15522 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15524 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15527 oa->write_character(to_char_type(0xCF));
15528 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15533 if (j.m_data.m_value.number_integer >= -32)
15536 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15538 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15539 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15542 oa->write_character(to_char_type(0xD0));
15543 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.number_integer));
15545 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15546 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15549 oa->write_character(to_char_type(0xD1));
15550 write_number(
static_cast<std::int16_t
>(j.m_data.m_value.number_integer));
15552 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15553 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15556 oa->write_character(to_char_type(0xD2));
15557 write_number(
static_cast<std::int32_t
>(j.m_data.m_value.number_integer));
15559 else if (j.m_data.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15560 j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15563 oa->write_character(to_char_type(0xD3));
15564 write_number(
static_cast<std::int64_t
>(j.m_data.m_value.number_integer));
15570 case value_t::number_unsigned:
15572 if (j.m_data.m_value.number_unsigned < 128)
15575 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15577 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15580 oa->write_character(to_char_type(0xCC));
15581 write_number(
static_cast<std::uint8_t
>(j.m_data.m_value.number_integer));
15583 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15586 oa->write_character(to_char_type(0xCD));
15587 write_number(
static_cast<std::uint16_t
>(j.m_data.m_value.number_integer));
15589 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15592 oa->write_character(to_char_type(0xCE));
15593 write_number(
static_cast<std::uint32_t
>(j.m_data.m_value.number_integer));
15595 else if (j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15598 oa->write_character(to_char_type(0xCF));
15599 write_number(
static_cast<std::uint64_t
>(j.m_data.m_value.number_integer));
15604 case value_t::number_float:
15610 case value_t::string:
15613 const auto N = j.m_data.m_value.string->size();
15617 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15619 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15622 oa->write_character(to_char_type(0xD9));
15623 write_number(
static_cast<std::uint8_t
>(N));
15625 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15628 oa->write_character(to_char_type(0xDA));
15629 write_number(
static_cast<std::uint16_t
>(N));
15631 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15634 oa->write_character(to_char_type(0xDB));
15635 write_number(
static_cast<std::uint32_t
>(N));
15639 oa->write_characters(
15640 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15641 j.m_data.m_value.string->size());
15645 case value_t::array:
15648 const auto N = j.m_data.m_value.array->size();
15652 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15654 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15657 oa->write_character(to_char_type(0xDC));
15658 write_number(
static_cast<std::uint16_t
>(N));
15660 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15663 oa->write_character(to_char_type(0xDD));
15664 write_number(
static_cast<std::uint32_t
>(N));
15668 for (
const auto& el : *j.m_data.m_value.array)
15675 case value_t::binary:
15679 const bool use_ext = j.m_data.m_value.binary->has_subtype();
15682 const auto N = j.m_data.m_value.binary->size();
15683 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15685 std::uint8_t output_type{};
15692 output_type = 0xD4;
15695 output_type = 0xD5;
15698 output_type = 0xD6;
15701 output_type = 0xD7;
15704 output_type = 0xD8;
15707 output_type = 0xC7;
15715 output_type = 0xC4;
15719 oa->write_character(to_char_type(output_type));
15722 write_number(
static_cast<std::uint8_t
>(N));
15725 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15727 const std::uint8_t output_type = use_ext
15731 oa->write_character(to_char_type(output_type));
15732 write_number(
static_cast<std::uint16_t
>(N));
15734 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15736 const std::uint8_t output_type = use_ext
15740 oa->write_character(to_char_type(output_type));
15741 write_number(
static_cast<std::uint32_t
>(N));
15747 write_number(
static_cast<std::int8_t
>(j.m_data.m_value.binary->subtype()));
15751 oa->write_characters(
15752 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15758 case value_t::object:
15761 const auto N = j.m_data.m_value.object->size();
15765 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15767 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15770 oa->write_character(to_char_type(0xDE));
15771 write_number(
static_cast<std::uint16_t
>(N));
15773 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15776 oa->write_character(to_char_type(0xDF));
15777 write_number(
static_cast<std::uint32_t
>(N));
15781 for (
const auto& el : *j.m_data.m_value.object)
15783 write_msgpack(el.first);
15784 write_msgpack(el.second);
15789 case value_t::discarded:
15803 const bool use_type,
const bool add_prefix =
true,
15804 const bool use_bjdata =
false)
15808 case value_t::null:
15812 oa->write_character(to_char_type(
'Z'));
15817 case value_t::boolean:
15821 oa->write_character(j.m_data.m_value.boolean
15822 ? to_char_type(
'T')
15823 : to_char_type(
'F'));
15828 case value_t::number_integer:
15830 write_number_with_ubjson_prefix(j.m_data.m_value.number_integer, add_prefix, use_bjdata);
15834 case value_t::number_unsigned:
15836 write_number_with_ubjson_prefix(j.m_data.m_value.number_unsigned, add_prefix, use_bjdata);
15840 case value_t::number_float:
15842 write_number_with_ubjson_prefix(j.m_data.m_value.number_float, add_prefix, use_bjdata);
15846 case value_t::string:
15850 oa->write_character(to_char_type(
'S'));
15852 write_number_with_ubjson_prefix(j.m_data.m_value.string->size(),
true, use_bjdata);
15853 oa->write_characters(
15854 reinterpret_cast<const CharType*
>(j.m_data.m_value.string->c_str()),
15855 j.m_data.m_value.string->size());
15859 case value_t::array:
15863 oa->write_character(to_char_type(
'['));
15866 bool prefix_required =
true;
15867 if (use_type && !j.m_data.m_value.array->empty())
15870 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15871 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15872 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15874 return ubjson_prefix(v, use_bjdata) == first_prefix;
15877 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15879 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15881 prefix_required =
false;
15882 oa->write_character(to_char_type(
'$'));
15883 oa->write_character(first_prefix);
15889 oa->write_character(to_char_type(
'#'));
15890 write_number_with_ubjson_prefix(j.m_data.m_value.array->size(),
true, use_bjdata);
15893 for (
const auto& el : *j.m_data.m_value.array)
15895 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15900 oa->write_character(to_char_type(
']'));
15906 case value_t::binary:
15910 oa->write_character(to_char_type(
'['));
15913 if (use_type && !j.m_data.m_value.binary->empty())
15916 oa->write_character(to_char_type(
'$'));
15917 oa->write_character(
'U');
15922 oa->write_character(to_char_type(
'#'));
15923 write_number_with_ubjson_prefix(j.m_data.m_value.binary->size(),
true, use_bjdata);
15928 oa->write_characters(
15929 reinterpret_cast<const CharType*
>(j.m_data.m_value.binary->data()),
15930 j.m_data.m_value.binary->size());
15934 for (
size_t i = 0; i < j.m_data.m_value.binary->size(); ++i)
15936 oa->write_character(to_char_type(
'U'));
15937 oa->write_character(j.m_data.m_value.binary->data()[i]);
15943 oa->write_character(to_char_type(
']'));
15949 case value_t::object:
15951 if (use_bjdata && j.m_data.m_value.object->size() == 3 && j.m_data.m_value.object->find(
"_ArrayType_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArraySize_") != j.m_data.m_value.object->end() && j.m_data.m_value.object->find(
"_ArrayData_") != j.m_data.m_value.object->end())
15953 if (!write_bjdata_ndarray(*j.m_data.m_value.object, use_count, use_type))
15961 oa->write_character(to_char_type(
'{'));
15964 bool prefix_required =
true;
15965 if (use_type && !j.m_data.m_value.object->empty())
15968 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15969 const bool same_prefix = std::all_of(j.begin(), j.end(),
15970 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15972 return ubjson_prefix(v, use_bjdata) == first_prefix;
15975 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15977 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15979 prefix_required =
false;
15980 oa->write_character(to_char_type(
'$'));
15981 oa->write_character(first_prefix);
15987 oa->write_character(to_char_type(
'#'));
15988 write_number_with_ubjson_prefix(j.m_data.m_value.object->size(),
true, use_bjdata);
15991 for (
const auto& el : *j.m_data.m_value.object)
15993 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15994 oa->write_characters(
15995 reinterpret_cast<const CharType*
>(el.first.c_str()),
15997 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
16002 oa->write_character(to_char_type(
'}'));
16008 case value_t::discarded:
16023 static std::size_t calc_bson_entry_header_size(
const string_t& name,
const BasicJsonType& j)
16025 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
16028 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
16029 static_cast<void>(j);
16032 return 1ul + name.size() + 1u;
16038 void write_bson_entry_header(
const string_t& name,
16039 const std::uint8_t element_type)
16041 oa->write_character(to_char_type(element_type));
16042 oa->write_characters(
16043 reinterpret_cast<const CharType*
>(name.c_str()),
16050 void write_bson_boolean(
const string_t& name,
16053 write_bson_entry_header(name, 0x08);
16054 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
16060 void write_bson_double(
const string_t& name,
16061 const double value)
16063 write_bson_entry_header(name, 0x01);
16064 write_number<double>(value,
true);
16070 static std::size_t calc_bson_string_size(
const string_t& value)
16072 return sizeof(std::int32_t) +
value.size() + 1ul;
16078 void write_bson_string(
const string_t& name,
16079 const string_t& value)
16081 write_bson_entry_header(name, 0x02);
16083 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
16084 oa->write_characters(
16085 reinterpret_cast<const CharType*
>(
value.c_str()),
16092 void write_bson_null(
const string_t& name)
16094 write_bson_entry_header(name, 0x0A);
16100 static std::size_t calc_bson_integer_size(
const std::int64_t value)
16102 return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
16103 ?
sizeof(std::int32_t)
16104 :
sizeof(std::int64_t);
16110 void write_bson_integer(
const string_t& name,
16111 const std::int64_t value)
16113 if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
16115 write_bson_entry_header(name, 0x10);
16116 write_number<std::int32_t>(
static_cast<std::int32_t
>(value),
true);
16120 write_bson_entry_header(name, 0x12);
16121 write_number<std::int64_t>(
static_cast<std::int64_t
>(value),
true);
16128 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value)
noexcept
16130 return (value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16131 ?
sizeof(std::int32_t)
16132 : sizeof(
std::int64_t);
16138 void write_bson_unsigned(
const string_t& name,
16139 const BasicJsonType& j)
16141 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16143 write_bson_entry_header(name, 0x10 );
16144 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_data.m_value.number_unsigned),
true);
16146 else if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16148 write_bson_entry_header(name, 0x12 );
16149 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_data.m_value.number_unsigned),
true);
16153 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_data.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16160 void write_bson_object_entry(
const string_t& name,
16161 const typename BasicJsonType::object_t& value)
16163 write_bson_entry_header(name, 0x03);
16164 write_bson_object(value);
16170 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
16172 std::size_t array_index = 0ul;
16174 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value),
static_cast<std::size_t
>(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16176 return result + calc_bson_element_size(std::to_string(array_index++), el);
16179 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16185 static std::size_t calc_bson_binary_size(
const typename BasicJsonType::binary_t& value)
16187 return sizeof(std::int32_t) +
value.size() + 1ul;
16193 void write_bson_array(
const string_t& name,
16194 const typename BasicJsonType::array_t& value)
16196 write_bson_entry_header(name, 0x04);
16197 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(value)),
true);
16199 std::size_t array_index = 0ul;
16201 for (
const auto& el : value)
16203 write_bson_element(std::to_string(array_index++), el);
16206 oa->write_character(to_char_type(0x00));
16212 void write_bson_binary(
const string_t& name,
16213 const binary_t& value)
16215 write_bson_entry_header(name, 0x05);
16217 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16218 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16220 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16227 static std::size_t calc_bson_element_size(
const string_t& name,
16228 const BasicJsonType& j)
16230 const auto header_size = calc_bson_entry_header_size(name, j);
16233 case value_t::object:
16234 return header_size + calc_bson_object_size(*j.m_data.m_value.object);
16236 case value_t::array:
16237 return header_size + calc_bson_array_size(*j.m_data.m_value.array);
16239 case value_t::binary:
16240 return header_size + calc_bson_binary_size(*j.m_data.m_value.binary);
16242 case value_t::boolean:
16243 return header_size + 1ul;
16245 case value_t::number_float:
16246 return header_size + 8ul;
16248 case value_t::number_integer:
16249 return header_size + calc_bson_integer_size(j.m_data.m_value.number_integer);
16251 case value_t::number_unsigned:
16252 return header_size + calc_bson_unsigned_size(j.m_data.m_value.number_unsigned);
16254 case value_t::string:
16255 return header_size + calc_bson_string_size(*j.m_data.m_value.string);
16257 case value_t::null:
16258 return header_size + 0ul;
16261 case value_t::discarded:
16275 void write_bson_element(
const string_t& name,
16276 const BasicJsonType& j)
16280 case value_t::object:
16281 return write_bson_object_entry(name, *j.m_data.m_value.object);
16283 case value_t::array:
16284 return write_bson_array(name, *j.m_data.m_value.array);
16286 case value_t::binary:
16287 return write_bson_binary(name, *j.m_data.m_value.binary);
16289 case value_t::boolean:
16290 return write_bson_boolean(name, j.m_data.m_value.boolean);
16292 case value_t::number_float:
16293 return write_bson_double(name, j.m_data.m_value.number_float);
16295 case value_t::number_integer:
16296 return write_bson_integer(name, j.m_data.m_value.number_integer);
16298 case value_t::number_unsigned:
16299 return write_bson_unsigned(name, j);
16301 case value_t::string:
16302 return write_bson_string(name, *j.m_data.m_value.string);
16304 case value_t::null:
16305 return write_bson_null(name);
16308 case value_t::discarded:
16322 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
16324 const std::size_t document_size = std::accumulate(
value.begin(),
value.end(),
static_cast<std::size_t
>(0),
16325 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16327 return result += calc_bson_element_size(el.first, el.second);
16330 return sizeof(std::int32_t) + document_size + 1ul;
16337 void write_bson_object(
const typename BasicJsonType::object_t& value)
16339 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(value)),
true);
16341 for (
const auto& el : value)
16343 write_bson_element(el.first, el.second);
16346 oa->write_character(to_char_type(0x00));
16353 static constexpr CharType get_cbor_float_prefix(
float )
16355 return to_char_type(0xFA);
16358 static constexpr CharType get_cbor_float_prefix(
double )
16360 return to_char_type(0xFB);
16367 static constexpr CharType get_msgpack_float_prefix(
float )
16369 return to_char_type(0xCA);
16372 static constexpr CharType get_msgpack_float_prefix(
double )
16374 return to_char_type(0xCB);
16382 template<
typename NumberType,
typename std::enable_if<
16383 std::is_floating_point<NumberType>::value,
int>::type = 0>
16384 void write_number_with_ubjson_prefix(
const NumberType n,
16385 const bool add_prefix,
16386 const bool use_bjdata)
16390 oa->write_character(get_ubjson_float_prefix(n));
16392 write_number(n, use_bjdata);
16396 template<
typename NumberType,
typename std::enable_if<
16397 std::is_unsigned<NumberType>::value,
int>::type = 0>
16398 void write_number_with_ubjson_prefix(
const NumberType n,
16399 const bool add_prefix,
16400 const bool use_bjdata)
16402 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16406 oa->write_character(to_char_type(
'i'));
16408 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16410 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16414 oa->write_character(to_char_type(
'U'));
16416 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16418 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16422 oa->write_character(to_char_type(
'I'));
16424 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16426 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
16430 oa->write_character(to_char_type(
'u'));
16432 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16434 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16438 oa->write_character(to_char_type(
'l'));
16440 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16442 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
16446 oa->write_character(to_char_type(
'm'));
16448 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16450 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16454 oa->write_character(to_char_type(
'L'));
16456 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16458 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16462 oa->write_character(to_char_type(
'M'));
16464 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16470 oa->write_character(to_char_type(
'H'));
16473 const auto number = BasicJsonType(n).dump();
16474 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16475 for (std::size_t i = 0; i < number.size(); ++i)
16477 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16483 template <
typename NumberType,
typename std::enable_if <
16484 std::is_signed<NumberType>::value&&
16485 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
16486 void write_number_with_ubjson_prefix(
const NumberType n,
16487 const bool add_prefix,
16488 const bool use_bjdata)
16490 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16494 oa->write_character(to_char_type(
'i'));
16496 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16498 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16502 oa->write_character(to_char_type(
'U'));
16504 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16506 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16510 oa->write_character(to_char_type(
'I'));
16512 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16514 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
16518 oa->write_character(to_char_type(
'u'));
16520 write_number(
static_cast<uint16_t
>(n), use_bjdata);
16522 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16526 oa->write_character(to_char_type(
'l'));
16528 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16530 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
16534 oa->write_character(to_char_type(
'm'));
16536 write_number(
static_cast<uint32_t
>(n), use_bjdata);
16538 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16542 oa->write_character(to_char_type(
'L'));
16544 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16551 oa->write_character(to_char_type(
'H'));
16554 const auto number = BasicJsonType(n).dump();
16555 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16556 for (std::size_t i = 0; i < number.size(); ++i)
16558 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16567 CharType ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16571 case value_t::null:
16574 case value_t::boolean:
16575 return j.m_data.m_value.boolean ?
'T' :
'F';
16577 case value_t::number_integer:
16579 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16583 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16587 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16591 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16595 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16599 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16603 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_data.m_value.number_integer && j.m_data.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16611 case value_t::number_unsigned:
16613 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16617 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16621 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16625 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16629 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16633 if (use_bjdata && j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16637 if (j.m_data.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16641 if (use_bjdata && j.m_data.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16649 case value_t::number_float:
16650 return get_ubjson_float_prefix(j.m_data.m_value.number_float);
16652 case value_t::string:
16655 case value_t::array:
16656 case value_t::binary:
16659 case value_t::object:
16662 case value_t::discarded:
16668 static constexpr CharType get_ubjson_float_prefix(
float )
16673 static constexpr CharType get_ubjson_float_prefix(
double )
16681 bool write_bjdata_ndarray(
const typename BasicJsonType::object_t& value,
const bool use_count,
const bool use_type)
16683 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16684 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16687 string_t
key =
"_ArrayType_";
16688 auto it = bjdtype.find(
static_cast<string_t
>(
value.at(key)));
16689 if (it == bjdtype.end())
16693 CharType dtype = it->second;
16695 key =
"_ArraySize_";
16696 std::size_t len = (
value.at(key).empty() ? 0 : 1);
16697 for (
const auto& el :
value.at(key))
16699 len *=
static_cast<std::size_t
>(el.m_data.m_value.number_unsigned);
16702 key =
"_ArrayData_";
16703 if (
value.at(key).size() != len)
16708 oa->write_character(
'[');
16709 oa->write_character(
'$');
16710 oa->write_character(dtype);
16711 oa->write_character(
'#');
16713 key =
"_ArraySize_";
16714 write_ubjson(
value.at(key), use_count, use_type,
true,
true);
16716 key =
"_ArrayData_";
16717 if (dtype ==
'U' || dtype ==
'C')
16719 for (
const auto& el :
value.at(key))
16721 write_number(
static_cast<std::uint8_t
>(el.m_data.m_value.number_unsigned),
true);
16724 else if (dtype ==
'i')
16726 for (
const auto& el :
value.at(key))
16728 write_number(
static_cast<std::int8_t
>(el.m_data.m_value.number_integer),
true);
16731 else if (dtype ==
'u')
16733 for (
const auto& el :
value.at(key))
16735 write_number(
static_cast<std::uint16_t
>(el.m_data.m_value.number_unsigned),
true);
16738 else if (dtype ==
'I')
16740 for (
const auto& el :
value.at(key))
16742 write_number(
static_cast<std::int16_t
>(el.m_data.m_value.number_integer),
true);
16745 else if (dtype ==
'm')
16747 for (
const auto& el :
value.at(key))
16749 write_number(
static_cast<std::uint32_t
>(el.m_data.m_value.number_unsigned),
true);
16752 else if (dtype ==
'l')
16754 for (
const auto& el :
value.at(key))
16756 write_number(
static_cast<std::int32_t
>(el.m_data.m_value.number_integer),
true);
16759 else if (dtype ==
'M')
16761 for (
const auto& el :
value.at(key))
16763 write_number(
static_cast<std::uint64_t
>(el.m_data.m_value.number_unsigned),
true);
16766 else if (dtype ==
'L')
16768 for (
const auto& el :
value.at(key))
16770 write_number(
static_cast<std::int64_t
>(el.m_data.m_value.number_integer),
true);
16773 else if (dtype ==
'd')
16775 for (
const auto& el :
value.at(key))
16777 write_number(
static_cast<float>(el.m_data.m_value.number_float),
true);
16780 else if (dtype ==
'D')
16782 for (
const auto& el :
value.at(key))
16784 write_number(
static_cast<double>(el.m_data.m_value.number_float),
true);
16807 template<
typename NumberType>
16808 void write_number(
const NumberType n,
const bool OutputIsLittleEndian =
false)
16811 std::array<CharType,
sizeof(NumberType)> vec{};
16812 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16815 if (is_little_endian != OutputIsLittleEndian)
16818 std::reverse(vec.begin(), vec.end());
16821 oa->write_characters(vec.data(),
sizeof(NumberType));
16827#pragma GCC diagnostic push
16828#pragma GCC diagnostic ignored "-Wfloat-equal"
16830 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16831 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16832 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
16835 ? get_cbor_float_prefix(
static_cast<float>(n))
16836 : get_msgpack_float_prefix(
static_cast<float>(n)));
16837 write_number(
static_cast<float>(n));
16842 ? get_cbor_float_prefix(n)
16843 : get_msgpack_float_prefix(n));
16847#pragma GCC diagnostic pop
16856 template <
typename C = CharType,
16857 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
16860 return *
reinterpret_cast<char*
>(&x);
16863 template <
typename C = CharType,
16864 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
16867 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16868 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16870 std::memcpy(&result, &x,
sizeof(x));
16874 template<
typename C = CharType,
16881 template <
typename InputCharType,
typename C = CharType,
16883 std::is_signed<C>::value &&
16884 std::is_signed<char>::value &&
16885 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16894 const bool is_little_endian = little_endianness();
16917#include <algorithm>
16927#include <type_traits>
16947#include <type_traits>
16978template<
typename Target,
typename Source>
16981 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16984 std::memcpy(&target, &source,
sizeof(Source));
16995 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
17006 return {x.f - y.f, x.e};
17015 static_assert(
kPrecision == 64,
"internal error");
17040 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
17041 const std::uint64_t u_hi = x.f >> 32u;
17042 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
17043 const std::uint64_t v_hi = y.f >> 32u;
17045 const std::uint64_t p0 = u_lo * v_lo;
17046 const std::uint64_t p1 = u_lo * v_hi;
17047 const std::uint64_t p2 = u_hi * v_lo;
17048 const std::uint64_t p3 = u_hi * v_hi;
17050 const std::uint64_t p0_hi = p0 >> 32u;
17051 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
17052 const std::uint64_t p1_hi = p1 >> 32u;
17053 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
17054 const std::uint64_t p2_hi = p2 >> 32u;
17056 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
17067 Q += std::uint64_t{1} << (64u - 32u - 1u);
17069 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
17071 return {h, x.e + y.e + 64};
17082 while ((x.f >> 63u) == 0)
17097 const int delta = x.e - target_exponent;
17102 return {x.f << delta, target_exponent};
17119template<
typename FloatType>
17132 static_assert(std::numeric_limits<FloatType>::is_iec559,
17133 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17135 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17136 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17137 constexpr int kMinExp = 1 - kBias;
17138 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17140 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17143 const std::uint64_t E = bits >> (kPrecision - 1);
17144 const std::uint64_t F = bits & (kHiddenBit - 1);
17146 const bool is_denormal = E == 0;
17147 const diyfp v = is_denormal
17148 ?
diyfp(F, kMinExp)
17149 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
17172 const bool lower_boundary_is_closer = F == 0 && E > 1;
17174 const diyfp m_minus = lower_boundary_is_closer
17175 ?
diyfp(4 * v.
f - 1, v.
e - 2)
17176 :
diyfp(2 * v.
f - 1, v.
e - 1);
17311 constexpr int kCachedPowersMinDecExp = -300;
17312 constexpr int kCachedPowersDecStep = 8;
17314 static constexpr std::array<cached_power, 79> kCachedPowers =
17317 { 0xAB70FE17C79AC6CA, -1060, -300 },
17318 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17319 { 0xBE5691EF416BD60C, -1007, -284 },
17320 { 0x8DD01FAD907FFC3C, -980, -276 },
17321 { 0xD3515C2831559A83, -954, -268 },
17322 { 0x9D71AC8FADA6C9B5, -927, -260 },
17323 { 0xEA9C227723EE8BCB, -901, -252 },
17324 { 0xAECC49914078536D, -874, -244 },
17325 { 0x823C12795DB6CE57, -847, -236 },
17326 { 0xC21094364DFB5637, -821, -228 },
17327 { 0x9096EA6F3848984F, -794, -220 },
17328 { 0xD77485CB25823AC7, -768, -212 },
17329 { 0xA086CFCD97BF97F4, -741, -204 },
17330 { 0xEF340A98172AACE5, -715, -196 },
17331 { 0xB23867FB2A35B28E, -688, -188 },
17332 { 0x84C8D4DFD2C63F3B, -661, -180 },
17333 { 0xC5DD44271AD3CDBA, -635, -172 },
17334 { 0x936B9FCEBB25C996, -608, -164 },
17335 { 0xDBAC6C247D62A584, -582, -156 },
17336 { 0xA3AB66580D5FDAF6, -555, -148 },
17337 { 0xF3E2F893DEC3F126, -529, -140 },
17338 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17339 { 0x87625F056C7C4A8B, -475, -124 },
17340 { 0xC9BCFF6034C13053, -449, -116 },
17341 { 0x964E858C91BA2655, -422, -108 },
17342 { 0xDFF9772470297EBD, -396, -100 },
17343 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17344 { 0xF8A95FCF88747D94, -343, -84 },
17345 { 0xB94470938FA89BCF, -316, -76 },
17346 { 0x8A08F0F8BF0F156B, -289, -68 },
17347 { 0xCDB02555653131B6, -263, -60 },
17348 { 0x993FE2C6D07B7FAC, -236, -52 },
17349 { 0xE45C10C42A2B3B06, -210, -44 },
17350 { 0xAA242499697392D3, -183, -36 },
17351 { 0xFD87B5F28300CA0E, -157, -28 },
17352 { 0xBCE5086492111AEB, -130, -20 },
17353 { 0x8CBCCC096F5088CC, -103, -12 },
17354 { 0xD1B71758E219652C, -77, -4 },
17355 { 0x9C40000000000000, -50, 4 },
17356 { 0xE8D4A51000000000, -24, 12 },
17357 { 0xAD78EBC5AC620000, 3, 20 },
17358 { 0x813F3978F8940984, 30, 28 },
17359 { 0xC097CE7BC90715B3, 56, 36 },
17360 { 0x8F7E32CE7BEA5C70, 83, 44 },
17361 { 0xD5D238A4ABE98068, 109, 52 },
17362 { 0x9F4F2726179A2245, 136, 60 },
17363 { 0xED63A231D4C4FB27, 162, 68 },
17364 { 0xB0DE65388CC8ADA8, 189, 76 },
17365 { 0x83C7088E1AAB65DB, 216, 84 },
17366 { 0xC45D1DF942711D9A, 242, 92 },
17367 { 0x924D692CA61BE758, 269, 100 },
17368 { 0xDA01EE641A708DEA, 295, 108 },
17369 { 0xA26DA3999AEF774A, 322, 116 },
17370 { 0xF209787BB47D6B85, 348, 124 },
17371 { 0xB454E4A179DD1877, 375, 132 },
17372 { 0x865B86925B9BC5C2, 402, 140 },
17373 { 0xC83553C5C8965D3D, 428, 148 },
17374 { 0x952AB45CFA97A0B3, 455, 156 },
17375 { 0xDE469FBD99A05FE3, 481, 164 },
17376 { 0xA59BC234DB398C25, 508, 172 },
17377 { 0xF6C69A72A3989F5C, 534, 180 },
17378 { 0xB7DCBF5354E9BECE, 561, 188 },
17379 { 0x88FCF317F22241E2, 588, 196 },
17380 { 0xCC20CE9BD35C78A5, 614, 204 },
17381 { 0x98165AF37B2153DF, 641, 212 },
17382 { 0xE2A0B5DC971F303A, 667, 220 },
17383 { 0xA8D9D1535CE3B396, 694, 228 },
17384 { 0xFB9B7CD9A4A7443C, 720, 236 },
17385 { 0xBB764C4CA7A44410, 747, 244 },
17386 { 0x8BAB8EEFB6409C1A, 774, 252 },
17387 { 0xD01FEF10A657842C, 800, 260 },
17388 { 0x9B10A4E5E9913129, 827, 268 },
17389 { 0xE7109BFBA19C0C9D, 853, 276 },
17390 { 0xAC2820D9623BF429, 880, 284 },
17391 { 0x80444B5E7AA7CF85, 907, 292 },
17392 { 0xBF21E44003ACDD2D, 933, 300 },
17393 { 0x8E679C2F5E44FF8F, 960, 308 },
17394 { 0xD433179D9C8CB841, 986, 316 },
17395 { 0x9E19DB92B4E31BA9, 1013, 324 },
17405 const int f =
kAlpha - e - 1;
17406 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
17408 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17410 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
17412 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
17426 if (n >= 1000000000)
17428 pow10 = 1000000000;
17432 if (n >= 100000000)
17477inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17478 std::uint64_t rest, std::uint64_t ten_k)
17505 && delta - rest >= ten_k
17506 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17521 static_assert(
kAlpha >= -60,
"internal error");
17522 static_assert(
kGamma <= -32,
"internal error");
17539 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
17549 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
17551 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
17552 std::uint64_t p2 = M_plus.
f & (one.f - 1);
17560 std::uint32_t pow10{};
17588 const std::uint32_t d = p1 / pow10;
17589 const std::uint32_t r = p1 % pow10;
17595 buffer[length++] =
static_cast<char>(
'0' + d);
17614 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17619 decimal_exponent += n;
17630 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17631 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17692 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17694 const std::uint64_t d = p2 >> -one.e;
17695 const std::uint64_t r = p2 & (one.f - 1);
17702 buffer[length++] =
static_cast<char>(
'0' + d);
17727 decimal_exponent -= m;
17735 const std::uint64_t ten_m = one.f;
17759inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17776 const diyfp c_minus_k(cached.
f, cached.
e);
17804 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
17805 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
17807 decimal_exponent = -cached.
k;
17817template<
typename FloatType>
17822 "internal error: not enough precision");
17874 auto k =
static_cast<std::uint32_t
>(e);
17880 *buf++ =
static_cast<char>(
'0' + k);
17884 *buf++ =
static_cast<char>(
'0' + k / 10);
17886 *buf++ =
static_cast<char>(
'0' + k);
17890 *buf++ =
static_cast<char>(
'0' + k / 100);
17892 *buf++ =
static_cast<char>(
'0' + k / 10);
17894 *buf++ =
static_cast<char>(
'0' + k);
17912 int min_exp,
int max_exp)
17918 const int n = len + decimal_exponent;
17924 if (k <= n && n <= max_exp)
17929 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
17933 return buf + (
static_cast<size_t>(n) + 2);
17936 if (0 < n && n <= max_exp)
17943 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
17945 return buf + (
static_cast<size_t>(k) + 1U);
17948 if (min_exp < n && n <= 0)
17953 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
17956 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
17957 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
17972 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17974 buf += 1 +
static_cast<size_t>(k);
17993template<
typename FloatType>
17998 static_cast<void>(last);
18002 if (std::signbit(
value))
18009#pragma GCC diagnostic push
18010#pragma GCC diagnostic ignored "-Wfloat-equal"
18021#pragma GCC diagnostic pop
18024 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
18031 int decimal_exponent = 0;
18034 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
18037 constexpr int kMinExp = -4;
18039 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
18042 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
18043 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
18082template<
typename BasicJsonType>
18085 using string_t =
typename BasicJsonType::string_t;
18086 using number_float_t =
typename BasicJsonType::number_float_t;
18087 using number_integer_t =
typename BasicJsonType::number_integer_t;
18088 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
18089 using binary_char_t =
typename BasicJsonType::binary_t::value_type;
18090 static constexpr std::uint8_t UTF8_ACCEPT = 0;
18091 static constexpr std::uint8_t UTF8_REJECT = 1;
18102 ,
loc(
std::localeconv())
18140 const bool pretty_print,
18142 const unsigned int indent_step,
18143 const unsigned int current_indent = 0)
18145 switch (val.m_data.m_type)
18149 if (val.m_data.m_value.object->empty())
18151 o->write_characters(
"{}", 2);
18157 o->write_characters(
"{\n", 2);
18160 const auto new_indent = current_indent + indent_step;
18167 auto i = val.m_data.m_value.object->cbegin();
18168 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18171 o->write_character(
'\"');
18173 o->write_characters(
"\": ", 3);
18175 o->write_characters(
",\n", 2);
18179 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18180 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18182 o->write_character(
'\"');
18184 o->write_characters(
"\": ", 3);
18187 o->write_character(
'\n');
18188 o->write_characters(
indent_string.c_str(), current_indent);
18189 o->write_character(
'}');
18193 o->write_character(
'{');
18196 auto i = val.m_data.m_value.object->cbegin();
18197 for (std::size_t cnt = 0; cnt < val.m_data.m_value.object->size() - 1; ++cnt, ++i)
18199 o->write_character(
'\"');
18201 o->write_characters(
"\":", 2);
18203 o->write_character(
',');
18207 JSON_ASSERT(i != val.m_data.m_value.object->cend());
18208 JSON_ASSERT(std::next(i) == val.m_data.m_value.object->cend());
18209 o->write_character(
'\"');
18211 o->write_characters(
"\":", 2);
18214 o->write_character(
'}');
18222 if (val.m_data.m_value.array->empty())
18224 o->write_characters(
"[]", 2);
18230 o->write_characters(
"[\n", 2);
18233 const auto new_indent = current_indent + indent_step;
18240 for (
auto i = val.m_data.m_value.array->cbegin();
18241 i != val.m_data.m_value.array->cend() - 1; ++i)
18245 o->write_characters(
",\n", 2);
18251 dump(val.m_data.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
18253 o->write_character(
'\n');
18254 o->write_characters(
indent_string.c_str(), current_indent);
18255 o->write_character(
']');
18259 o->write_character(
'[');
18262 for (
auto i = val.m_data.m_value.array->cbegin();
18263 i != val.m_data.m_value.array->cend() - 1; ++i)
18266 o->write_character(
',');
18271 dump(val.m_data.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
18273 o->write_character(
']');
18281 o->write_character(
'\"');
18282 dump_escaped(*val.m_data.m_value.string,
ensure_ascii);
18283 o->write_character(
'\"');
18291 o->write_characters(
"{\n", 2);
18294 const auto new_indent = current_indent + indent_step;
18302 o->write_characters(
"\"bytes\": [", 10);
18304 if (!val.m_data.m_value.binary->empty())
18306 for (
auto i = val.m_data.m_value.binary->cbegin();
18307 i != val.m_data.m_value.binary->cend() - 1; ++i)
18310 o->write_characters(
", ", 2);
18312 dump_integer(val.m_data.m_value.binary->back());
18315 o->write_characters(
"],\n", 3);
18318 o->write_characters(
"\"subtype\": ", 11);
18319 if (val.m_data.m_value.binary->has_subtype())
18321 dump_integer(val.m_data.m_value.binary->subtype());
18325 o->write_characters(
"null", 4);
18327 o->write_character(
'\n');
18328 o->write_characters(
indent_string.c_str(), current_indent);
18329 o->write_character(
'}');
18333 o->write_characters(
"{\"bytes\":[", 10);
18335 if (!val.m_data.m_value.binary->empty())
18337 for (
auto i = val.m_data.m_value.binary->cbegin();
18338 i != val.m_data.m_value.binary->cend() - 1; ++i)
18341 o->write_character(
',');
18343 dump_integer(val.m_data.m_value.binary->back());
18346 o->write_characters(
"],\"subtype\":", 12);
18347 if (val.m_data.m_value.binary->has_subtype())
18349 dump_integer(val.m_data.m_value.binary->subtype());
18350 o->write_character(
'}');
18354 o->write_characters(
"null}", 5);
18362 if (val.m_data.m_value.boolean)
18364 o->write_characters(
"true", 4);
18368 o->write_characters(
"false", 5);
18375 dump_integer(val.m_data.m_value.number_integer);
18381 dump_integer(val.m_data.m_value.number_unsigned);
18387 dump_float(val.m_data.m_value.number_float);
18393 o->write_characters(
"<discarded>", 11);
18399 o->write_characters(
"null", 4);
18425 std::uint32_t codepoint{};
18433 for (std::size_t i = 0; i < s.size(); ++i)
18435 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18437 switch (decode(
state, codepoint,
byte))
18496 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
18498 if (codepoint <= 0xFFFF)
18502 static_cast<std::uint16_t
>(codepoint)));
18508 static_cast<void>((std::snprintf)(
string_buffer.data() +
bytes, 13,
"\\u%04x\\u%04x",
18509 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18510 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18598 state = UTF8_ACCEPT;
18654 o->write_characters(
"\\ufffd", 6);
18658 o->write_characters(
"\xEF\xBF\xBD", 3);
18678 inline unsigned int count_digits(number_unsigned_t x)
noexcept
18680 unsigned int n_digits = 1;
18689 return n_digits + 1;
18693 return n_digits + 2;
18697 return n_digits + 3;
18709 static std::string hex_bytes(std::uint8_t
byte)
18711 std::string result =
"FF";
18712 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18713 result[0] = nibble_to_hex[
byte / 16];
18714 result[1] = nibble_to_hex[
byte % 16];
18719 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18720 bool is_negative_number(NumberType x)
18725 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18726 bool is_negative_number(NumberType )
18741 std::is_integral<NumberType>::value ||
18742 std::is_same<NumberType, number_unsigned_t>::value ||
18743 std::is_same<NumberType, number_integer_t>::value ||
18744 std::is_same<NumberType, binary_char_t>::value,
18746 void dump_integer(NumberType x)
18748 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18751 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18752 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18753 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18754 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18755 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18756 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18757 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18758 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18759 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18760 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18767 o->write_character(
'0');
18774 number_unsigned_t abs_value;
18776 unsigned int n_chars{};
18778 if (is_negative_number(x))
18781 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
18784 n_chars = 1 + count_digits(abs_value);
18788 abs_value =
static_cast<number_unsigned_t
>(x);
18789 n_chars = count_digits(abs_value);
18797 buffer_ptr += n_chars;
18801 while (abs_value >= 100)
18803 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18805 *(--buffer_ptr) = digits_to_99[digits_index][1];
18806 *(--buffer_ptr) = digits_to_99[digits_index][0];
18809 if (abs_value >= 10)
18811 const auto digits_index =
static_cast<unsigned>(abs_value);
18812 *(--buffer_ptr) = digits_to_99[digits_index][1];
18813 *(--buffer_ptr) = digits_to_99[digits_index][0];
18817 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18831 void dump_float(number_float_t x)
18834 if (!std::isfinite(x))
18836 o->write_characters(
"null", 4);
18845 static constexpr bool is_ieee_single_or_double
18846 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
18847 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
18849 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18852 void dump_float(number_float_t x, std::true_type )
18855 auto* end = ::nlohmann::detail::to_chars(begin, begin +
number_buffer.size(), x);
18857 o->write_characters(begin,
static_cast<size_t>(end - begin));
18860 void dump_float(number_float_t x, std::false_type )
18863 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18895 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
18898 const bool value_is_int_like =
18902 return c ==
'.' || c ==
'e';
18905 if (value_is_int_like)
18907 o->write_characters(
".0", 2);
18932 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18934 static const std::array<std::uint8_t, 400> utf8d =
18937 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18938 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18939 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18940 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18941 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
18942 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18943 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18944 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18945 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18946 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18947 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
18948 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
18949 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
18950 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
18955 const std::uint8_t type = utf8d[byte];
18957 codep = (
state != UTF8_ACCEPT)
18958 ? (
byte & 0x3fu) | (codep << 6u)
18959 : (0xFFu >> type) & (byte);
18961 const std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
18963 state = utf8d[index];
18972 number_unsigned_t remove_sign(number_unsigned_t x)
18987 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
18989 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18990 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
19037#include <functional>
19038#include <initializer_list>
19041#include <stdexcept>
19042#include <type_traits>
19055template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
19056 class Allocator = std::allocator<std::pair<const Key, T>>>
19061 using Container = std::vector<std::pair<const Key, T>, Allocator>;
19066#ifdef JSON_HAS_CPP_14
19076 template <
class It>
19079 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
19084 for (
auto it = this->begin(); it != this->end(); ++it)
19086 if (m_compare(it->first, key))
19088 return {it,
false};
19091 Container::emplace_back(key, std::forward<T>(t));
19092 return {std::prev(this->end()),
true};
19097 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
19099 for (
auto it = this->begin(); it != this->end(); ++it)
19101 if (m_compare(it->first, key))
19103 return {it,
false};
19106 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
19107 return {std::prev(this->end()),
true};
19112 return emplace(key, T{}).first->second;
19119 return emplace(std::forward<KeyType>(key), T{}).first->second;
19131 return at(std::forward<KeyType>(key));
19136 for (
auto it = this->begin(); it != this->end(); ++it)
19138 if (m_compare(it->first, key))
19144 JSON_THROW(std::out_of_range(
"key not found"));
19151 for (
auto it = this->begin(); it != this->end(); ++it)
19153 if (m_compare(it->first, key))
19159 JSON_THROW(std::out_of_range(
"key not found"));
19164 for (
auto it = this->begin(); it != this->end(); ++it)
19166 if (m_compare(it->first, key))
19172 JSON_THROW(std::out_of_range(
"key not found"));
19177 const T &
at(KeyType && key)
const
19179 for (
auto it = this->begin(); it != this->end(); ++it)
19181 if (m_compare(it->first, key))
19187 JSON_THROW(std::out_of_range(
"key not found"));
19192 for (
auto it = this->begin(); it != this->end(); ++it)
19194 if (m_compare(it->first, key))
19197 for (
auto next = it; ++next != this->end(); ++it)
19202 Container::pop_back();
19213 for (
auto it = this->begin(); it != this->end(); ++it)
19215 if (m_compare(it->first, key))
19218 for (
auto next = it; ++next != this->end(); ++it)
19223 Container::pop_back();
19232 return erase(pos, std::next(pos));
19242 const auto elements_affected = std::distance(first, last);
19243 const auto offset = std::distance(Container::begin(), first);
19265 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19268 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19276 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
19285 return Container::begin() + offset;
19290 for (
auto it = this->begin(); it != this->end(); ++it)
19292 if (m_compare(it->first, key))
19304 for (
auto it = this->begin(); it != this->end(); ++it)
19306 if (m_compare(it->first, key))
19316 for (
auto it = this->begin(); it != this->end(); ++it)
19318 if (m_compare(it->first, key))
19323 return Container::end();
19330 for (
auto it = this->begin(); it != this->end(); ++it)
19332 if (m_compare(it->first, key))
19337 return Container::end();
19342 for (
auto it = this->begin(); it != this->end(); ++it)
19344 if (m_compare(it->first, key))
19349 return Container::end();
19354 return emplace(value.first, std::move(value.second));
19359 for (
auto it = this->begin(); it != this->end(); ++it)
19361 if (m_compare(it->first, value.first))
19363 return {it,
false};
19366 Container::push_back(value);
19367 return {--this->end(),
true};
19370 template<
typename InputIt>
19371 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19372 std::input_iterator_tag>::value>::type;
19374 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19377 for (
auto it = first; it != last; ++it)
19390#if defined(JSON_HAS_CPP_17)
19391 #if JSON_HAS_STATIC_RTTI
19394 #include <string_view>
19424 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
19430 friend class ::nlohmann::json_pointer;
19434 template<
typename BasicJsonType,
typename InputType>
19435 friend class ::nlohmann::detail::parser;
19436 friend ::nlohmann::detail::serializer<basic_json>;
19437 template<
typename BasicJsonType>
19438 friend class ::nlohmann::detail::iter_impl;
19439 template<
typename BasicJsonType,
typename CharType>
19440 friend class ::nlohmann::detail::binary_writer;
19441 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19442 friend class ::nlohmann::detail::binary_reader;
19443 template<
typename BasicJsonType>
19444 friend class ::nlohmann::detail::json_sax_dom_parser;
19445 template<
typename BasicJsonType>
19446 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19447 friend class ::nlohmann::detail::exception;
19451 using json_base_class_t = ::nlohmann::detail::json_base_class<CustomBaseClass>;
19455 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19457 template<
typename InputAdapterType>
19458 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19459 InputAdapterType adapter,
19461 const bool allow_exceptions =
true,
19462 const bool ignore_comments =
false
19465 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19466 std::move(cb), allow_exceptions, ignore_comments);
19470 using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
19471 template<
typename BasicJsonType>
19472 using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
19473 template<
typename BasicJsonType>
19474 using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
19475 template<
typename Iterator>
19476 using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
19477 template<
typename Base>
using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
19479 template<
typename CharType>
19480 using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
19482 template<
typename InputType>
19483 using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
19484 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19487 using serializer = ::nlohmann::detail::serializer<basic_json>;
19493 template<
typename T,
typename SFINAE>
19549 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19551 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19578 result[
"copyright"] =
"(C) 2013-2023 Niels Lohmann";
19579 result[
"name"] =
"JSON for Modern C++";
19580 result[
"url"] =
"https://github.com/nlohmann/json";
19581 result[
"version"][
"string"] =
19590 result[
"platform"] =
"win32";
19591#elif defined __linux__
19592 result[
"platform"] =
"linux";
19593#elif defined __APPLE__
19594 result[
"platform"] =
"apple";
19595#elif defined __unix__
19596 result[
"platform"] =
"unix";
19598 result[
"platform"] =
"unknown";
19601#if defined(__ICC) || defined(__INTEL_COMPILER)
19602 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19603#elif defined(__clang__)
19604 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19605#elif defined(__GNUC__) || defined(__GNUG__)
19606 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19607 std::to_string(__GNUC__),
'.',
19608 std::to_string(__GNUC_MINOR__),
'.',
19609 std::to_string(__GNUC_PATCHLEVEL__))
19612#elif defined(__HP_cc) || defined(__HP_aCC)
19613 result[
"compiler"] =
"hp"
19614#elif defined(__IBMCPP__)
19615 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19616#elif defined(_MSC_VER)
19617 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19618#elif defined(__PGI)
19619 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19620#elif defined(__SUNPRO_CC)
19621 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19623 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19626#if defined(_MSVC_LANG)
19627 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
19628#elif defined(__cplusplus)
19629 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
19631 result[
"compiler"][
"c++"] =
"unknown";
19649#if defined(JSON_HAS_CPP_14)
19662 AllocatorType<std::pair<
const StringType,
19667 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19691 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19702 template<
typename T,
typename... Args>
19704 static T* create(Args&& ... args)
19706 AllocatorType<T> alloc;
19707 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19709 auto deleter = [&](T * obj)
19711 AllocatorTraits::deallocate(alloc, obj, 1);
19713 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19714 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19716 return obj.release();
19769 json_value() =
default;
19771 json_value(
boolean_t v) noexcept : boolean(v) {}
19783 case value_t::object:
19785 object = create<object_t>();
19789 case value_t::array:
19791 array = create<array_t>();
19795 case value_t::string:
19797 string = create<string_t>(
"");
19801 case value_t::binary:
19803 binary = create<binary_t>();
19807 case value_t::boolean:
19809 boolean =
static_cast<boolean_t>(
false);
19813 case value_t::number_integer:
19819 case value_t::number_unsigned:
19825 case value_t::number_float:
19831 case value_t::null:
19837 case value_t::discarded:
19883 (t == value_t::object &&
object ==
nullptr) ||
19884 (t == value_t::array && array ==
nullptr) ||
19885 (t == value_t::string &&
string ==
nullptr) ||
19886 (t == value_t::binary && binary ==
nullptr)
19892 if (t == value_t::array || t == value_t::object)
19895 std::vector<basic_json> stack;
19898 if (t == value_t::array)
19900 stack.reserve(
array->size());
19901 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
19906 for (
auto&& it : *
object)
19908 stack.push_back(std::move(it.second));
19912 while (!stack.empty())
19915 basic_json current_item(std::move(stack.back()));
19920 if (current_item.is_array())
19922 std::move(current_item.m_data.m_value.array->begin(), current_item.m_data.m_value.array->end(), std::back_inserter(stack));
19924 current_item.m_data.m_value.array->clear();
19926 else if (current_item.is_object())
19928 for (
auto&& it : *current_item.m_data.m_value.object)
19930 stack.push_back(std::move(it.second));
19933 current_item.m_data.m_value.object->clear();
19943 case value_t::object:
19945 AllocatorType<object_t> alloc;
19946 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
19947 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
19951 case value_t::array:
19953 AllocatorType<array_t> alloc;
19954 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
19955 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
19959 case value_t::string:
19961 AllocatorType<string_t> alloc;
19962 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
19963 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
19967 case value_t::binary:
19969 AllocatorType<binary_t> alloc;
19970 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
19971 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
19975 case value_t::null:
19976 case value_t::boolean:
19977 case value_t::number_integer:
19978 case value_t::number_unsigned:
19979 case value_t::number_float:
19980 case value_t::discarded:
20008 void assert_invariant(
bool check_parents =
true) const noexcept
20015#if JSON_DIAGNOSTICS
20021 return j.m_parent ==
this;
20026 static_cast<void>(check_parents);
20031#if JSON_DIAGNOSTICS
20034 case value_t::array:
20036 for (
auto& element : *
m_data.m_value.array)
20038 element.m_parent =
this;
20043 case value_t::object:
20045 for (
auto& element : *
m_data.m_value.object)
20047 element.second.m_parent =
this;
20052 case value_t::null:
20053 case value_t::string:
20054 case value_t::boolean:
20055 case value_t::number_integer:
20056 case value_t::number_unsigned:
20057 case value_t::number_float:
20058 case value_t::binary:
20059 case value_t::discarded:
20066 iterator set_parents(
iterator it,
typename iterator::difference_type count_set_parents)
20068#if JSON_DIAGNOSTICS
20069 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
20071 (it + i)->m_parent =
this;
20074 static_cast<void>(count_set_parents);
20079 reference set_parent(
reference j, std::size_t old_capacity =
static_cast<std::size_t
>(-1))
20081#if JSON_DIAGNOSTICS
20082 if (old_capacity !=
static_cast<std::size_t
>(-1))
20096#ifdef JSON_HEDLEY_MSVC_VERSION
20097#pragma warning(push )
20098#pragma warning(disable : 4127)
20105#ifdef JSON_HEDLEY_MSVC_VERSION
20106#pragma warning( pop )
20111 static_cast<void>(j);
20112 static_cast<void>(old_capacity);
20144 assert_invariant();
20152 assert_invariant();
20157 template <
typename CompatibleType,
20162 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20163 std::forward<CompatibleType>(val))))
20165 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20167 assert_invariant();
20172 template <
typename BasicJsonType,
20177 using other_boolean_t =
typename BasicJsonType::boolean_t;
20178 using other_number_float_t =
typename BasicJsonType::number_float_t;
20179 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20180 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20181 using other_string_t =
typename BasicJsonType::string_t;
20182 using other_object_t =
typename BasicJsonType::object_t;
20183 using other_array_t =
typename BasicJsonType::array_t;
20184 using other_binary_t =
typename BasicJsonType::binary_t;
20186 switch (val.type())
20188 case value_t::boolean:
20191 case value_t::number_float:
20194 case value_t::number_integer:
20197 case value_t::number_unsigned:
20200 case value_t::string:
20203 case value_t::object:
20206 case value_t::array:
20209 case value_t::binary:
20212 case value_t::null:
20215 case value_t::discarded:
20216 m_data.m_type = value_t::discarded;
20223 assert_invariant();
20229 bool type_deduction =
true,
20230 value_t manual_type = value_t::array)
20234 bool is_an_object = std::all_of(init.begin(), init.end(),
20240 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
20244 if (!type_deduction)
20247 if (manual_type == value_t::array)
20249 is_an_object =
false;
20262 m_data.m_type = value_t::object;
20263 m_data.m_value = value_t::object;
20265 for (
auto& element_ref : init)
20269 std::move(*((*element.m_data.m_value.array)[0].m_data.m_value.string)),
20270 std::move((*element.m_data.m_value.array)[1]));
20276 m_data.m_type = value_t::array;
20277 m_data.m_value.array = create<array_t>(init.begin(), init.end());
20281 assert_invariant();
20290 res.m_data.m_type = value_t::binary;
20291 res.m_data.m_value = init;
20298 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20301 res.m_data.m_type = value_t::binary;
20302 res.m_data.m_value =
binary_t(init, subtype);
20312 res.m_data.m_type = value_t::binary;
20313 res.m_data.m_value = std::move(init);
20320 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20323 res.m_data.m_type = value_t::binary;
20324 res.m_data.m_value =
binary_t(std::move(init), subtype);
20333 return basic_json(init,
false, value_t::array);
20341 return basic_json(init,
false, value_t::object);
20350 assert_invariant();
20355 template <
class InputIT,
typename std::enable_if <
20356 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20357 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
20370 m_data.m_type = first.m_object->m_data.m_type;
20375 case value_t::boolean:
20376 case value_t::number_float:
20377 case value_t::number_integer:
20378 case value_t::number_unsigned:
20379 case value_t::string:
20382 || !last.m_it.primitive_iterator.is_end()))
20389 case value_t::null:
20390 case value_t::object:
20391 case value_t::array:
20392 case value_t::binary:
20393 case value_t::discarded:
20400 case value_t::number_integer:
20402 m_data.m_value.number_integer = first.m_object->m_data.m_value.number_integer;
20406 case value_t::number_unsigned:
20408 m_data.m_value.number_unsigned = first.m_object->m_data.m_value.number_unsigned;
20412 case value_t::number_float:
20414 m_data.m_value.number_float = first.m_object->m_data.m_value.number_float;
20418 case value_t::boolean:
20420 m_data.m_value.boolean = first.m_object->m_data.m_value.boolean;
20424 case value_t::string:
20426 m_data.m_value = *first.m_object->m_data.m_value.string;
20430 case value_t::object:
20432 m_data.m_value.object = create<object_t>(first.m_it.object_iterator,
20433 last.m_it.object_iterator);
20437 case value_t::array:
20439 m_data.m_value.array = create<array_t>(first.m_it.array_iterator,
20440 last.m_it.array_iterator);
20444 case value_t::binary:
20446 m_data.m_value = *first.m_object->m_data.m_value.binary;
20450 case value_t::null:
20451 case value_t::discarded:
20457 assert_invariant();
20464 template<
typename JsonRef,
20466 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
20472 : json_base_class_t(other)
20476 other.assert_invariant();
20480 case value_t::object:
20482 m_data.m_value = *other.m_data.m_value.object;
20486 case value_t::array:
20488 m_data.m_value = *other.m_data.m_value.array;
20492 case value_t::string:
20494 m_data.m_value = *other.m_data.m_value.string;
20498 case value_t::boolean:
20500 m_data.m_value = other.m_data.m_value.boolean;
20504 case value_t::number_integer:
20506 m_data.m_value = other.m_data.m_value.number_integer;
20510 case value_t::number_unsigned:
20512 m_data.m_value = other.m_data.m_value.number_unsigned;
20516 case value_t::number_float:
20518 m_data.m_value = other.m_data.m_value.number_float;
20522 case value_t::binary:
20524 m_data.m_value = *other.m_data.m_value.binary;
20528 case value_t::null:
20529 case value_t::discarded:
20535 assert_invariant();
20541 : json_base_class_t(std::forward<json_base_class_t>(other)),
20542 m_data(std::move(other.m_data))
20545 other.assert_invariant(
false);
20548 other.m_data.m_type = value_t::null;
20549 other.m_data.m_value = {};
20552 assert_invariant();
20558 std::is_nothrow_move_constructible<value_t>::value&&
20559 std::is_nothrow_move_assignable<value_t>::value&&
20560 std::is_nothrow_move_constructible<json_value>::value&&
20561 std::is_nothrow_move_assignable<json_value>::value&&
20562 std::is_nothrow_move_assignable<json_base_class_t>::value
20566 other.assert_invariant();
20569 swap(m_data.m_type, other.m_data.m_type);
20570 swap(m_data.m_value, other.m_data.m_value);
20571 json_base_class_t::operator=(std::move(other));
20574 assert_invariant();
20582 assert_invariant(
false);
20599 const char indent_char =
' ',
20600 const bool ensure_ascii =
false,
20608 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20612 s.dump(*
this,
false, ensure_ascii, 0);
20622 return m_data.m_type;
20629 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
20636 return is_array() || is_object();
20643 return m_data.m_type == value_t::null;
20650 return m_data.m_type == value_t::boolean;
20657 return is_number_integer() || is_number_float();
20664 return m_data.m_type == value_t::number_integer || m_data.m_type == value_t::number_unsigned;
20671 return m_data.m_type == value_t::number_unsigned;
20678 return m_data.m_type == value_t::number_float;
20685 return m_data.m_type == value_t::object;
20692 return m_data.m_type == value_t::array;
20699 return m_data.m_type == value_t::string;
20706 return m_data.m_type == value_t::binary;
20713 return m_data.m_type == value_t::discarded;
20720 return m_data.m_type;
20731 boolean_t get_impl(boolean_t* )
const
20735 return m_data.m_value.boolean;
20742 object_t* get_impl_ptr(object_t* )
noexcept
20744 return is_object() ? m_data.m_value.object :
nullptr;
20748 constexpr const object_t* get_impl_ptr(
const object_t* )
const noexcept
20750 return is_object() ? m_data.m_value.object :
nullptr;
20754 array_t* get_impl_ptr(array_t* )
noexcept
20756 return is_array() ? m_data.m_value.array :
nullptr;
20760 constexpr const array_t* get_impl_ptr(
const array_t* )
const noexcept
20762 return is_array() ? m_data.m_value.array :
nullptr;
20766 string_t* get_impl_ptr(string_t* )
noexcept
20768 return is_string() ? m_data.m_value.string :
nullptr;
20772 constexpr const string_t* get_impl_ptr(
const string_t* )
const noexcept
20774 return is_string() ? m_data.m_value.string :
nullptr;
20778 boolean_t* get_impl_ptr(boolean_t* )
noexcept
20780 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
20784 constexpr const boolean_t* get_impl_ptr(
const boolean_t* )
const noexcept
20786 return is_boolean() ? &m_data.m_value.boolean :
nullptr;
20790 number_integer_t* get_impl_ptr(number_integer_t* )
noexcept
20792 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
20796 constexpr const number_integer_t* get_impl_ptr(
const number_integer_t* )
const noexcept
20798 return is_number_integer() ? &m_data.m_value.number_integer :
nullptr;
20802 number_unsigned_t* get_impl_ptr(number_unsigned_t* )
noexcept
20804 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
20808 constexpr const number_unsigned_t* get_impl_ptr(
const number_unsigned_t* )
const noexcept
20810 return is_number_unsigned() ? &m_data.m_value.number_unsigned :
nullptr;
20814 number_float_t* get_impl_ptr(number_float_t* )
noexcept
20816 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
20820 constexpr const number_float_t* get_impl_ptr(
const number_float_t* )
const noexcept
20822 return is_number_float() ? &m_data.m_value.number_float :
nullptr;
20826 binary_t* get_impl_ptr(binary_t* )
noexcept
20828 return is_binary() ? m_data.m_value.binary :
nullptr;
20832 constexpr const binary_t* get_impl_ptr(
const binary_t* )
const noexcept
20834 return is_binary() ? m_data.m_value.binary :
nullptr;
20848 template<
typename ReferenceType,
typename ThisType>
20849 static ReferenceType get_ref_impl(ThisType& obj)
20852 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20859 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
20869 template<
typename PointerType,
typename std::enable_if<
20870 std::is_pointer<PointerType>::value,
int>::type = 0>
20871 auto get_ptr() noexcept -> decltype(
std::declval<basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20874 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20879 template <
typename PointerType,
typename std::enable_if <
20880 std::is_pointer<PointerType>::value&&
20881 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
20882 constexpr auto get_ptr() const noexcept -> decltype(
std::declval<const basic_json_t&>().get_impl_ptr(
std::declval<PointerType>()))
20885 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20927 template <
typename ValueType,
20933 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20935 auto ret = ValueType();
20936 JSONSerializer<ValueType>::from_json(*
this, ret);
20970 template <
typename ValueType,
20975 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20977 return JSONSerializer<ValueType>::from_json(*
this);
20995 template <
typename BasicJsonType,
21018 template<
typename BasicJsonType,
21020 std::is_same<BasicJsonType, basic_json_t>::value,
21031 template<
typename PointerType,
21033 std::is_pointer<PointerType>::value,
21036 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
21039 return get_ptr<PointerType>();
21066 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
21067#if defined(JSON_HAS_CPP_14)
21071 noexcept(
std::declval<const basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
21077 static_assert(!std::is_reference<ValueTypeCV>::value,
21078 "get() cannot be used with reference types, you might want to use get_ref()");
21109 template<
typename PointerType,
typename std::enable_if<
21110 std::is_pointer<PointerType>::value,
int>::type = 0>
21111 auto get() noexcept -> decltype(
std::declval<basic_json_t&>().template get_ptr<PointerType>())
21114 return get_ptr<PointerType>();
21119 template <
typename ValueType,
21124 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21125 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21127 JSONSerializer<ValueType>::from_json(*
this, v);
21133 template<
typename ValueType,
21144 typename T, std::size_t N,
21145 typename Array = T (&)[N],
21149 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21150 std::declval<const basic_json_t&>(), v)))
21152 JSONSerializer<Array>::from_json(*
this, v);
21158 template<
typename ReferenceType,
typename std::enable_if<
21159 std::is_reference<ReferenceType>::value,
int>::type = 0>
21163 return get_ref_impl<ReferenceType>(*
this);
21168 template <
typename ReferenceType,
typename std::enable_if <
21169 std::is_reference<ReferenceType>::value&&
21170 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21174 return get_ref_impl<ReferenceType>(*
this);
21206 template <
typename ValueType,
typename std::enable_if <
21214#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21217#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
21221 >::value,
int >::type = 0 >
21225 return get<ValueType>();
21237 return *get_ptr<binary_t*>();
21249 return *get_ptr<const binary_t*>();
21271 return set_parent(m_data.m_value.array->at(idx));
21276 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
21294 return m_data.m_value.array->at(idx);
21299 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
21318 auto it = m_data.
m_value.object->find(key);
21319 if (it == m_data.m_value.object->end())
21323 return set_parent(it->second);
21338 auto it = m_data.
m_value.object->find(std::forward<KeyType>(key));
21339 if (it == m_data.m_value.object->end())
21343 return set_parent(it->second);
21356 auto it = m_data.
m_value.object->find(key);
21357 if (it == m_data.m_value.object->end())
21376 auto it = m_data.
m_value.object->find(std::forward<KeyType>(key));
21377 if (it == m_data.m_value.object->end())
21391 m_data.m_type = value_t::array;
21392 m_data.m_value.array = create<array_t>();
21393 assert_invariant();
21400 if (idx >= m_data.m_value.array->size())
21402#if JSON_DIAGNOSTICS
21404 const auto old_size = m_data.m_value.array->size();
21405 const auto old_capacity = m_data.m_value.array->capacity();
21407 m_data.m_value.array->resize(idx + 1);
21409#if JSON_DIAGNOSTICS
21418 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21421 assert_invariant();
21424 return m_data.m_value.array->operator[](idx);
21427 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21437 return m_data.m_value.array->operator[](idx);
21440 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21450 m_data.m_type = value_t::object;
21451 m_data.m_value.object = create<object_t>();
21452 assert_invariant();
21458 auto result = m_data.m_value.object->emplace(std::move(key),
nullptr);
21459 return set_parent(result.first->second);
21462 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21472 auto it = m_data.m_value.object->find(key);
21477 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21482 template<
typename T>
21485 return operator[](
typename object_t::key_type(key));
21488 template<
typename T>
21491 return operator[](
typename object_t::key_type(key));
21503 m_data.m_type = value_t::object;
21504 m_data.m_value.object = create<object_t>();
21505 assert_invariant();
21511 auto result = m_data.m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21512 return set_parent(result.first->second);
21515 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21527 auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
21532 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21536 template<
typename KeyType>
21538 object_comparator_t,
const typename object_t::key_type&, KeyType >;
21540 template<
typename ValueType>
21541 using value_return_type = std::conditional <
21543 string_t,
typename std::decay<ValueType>::type >;
21551 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21552 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21558 const auto it = find(key);
21561 return it->template get<ValueType>();
21564 return default_value;
21572 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21576 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21577 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
21583 const auto it = find(key);
21586 return it->template get<ReturnType>();
21589 return std::forward<ValueType>(default_value);
21600 && is_comparable_with_object_key<KeyType>::value
21602 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21603 ValueType
value(KeyType && key,
const ValueType& default_value)
const
21609 const auto it = find(std::forward<KeyType>(key));
21612 return it->template get<ValueType>();
21615 return default_value;
21623 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21627 && is_comparable_with_object_key<KeyType>::value
21629 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21630 ReturnType
value(KeyType && key, ValueType && default_value)
const
21636 const auto it = find(std::forward<KeyType>(key));
21639 return it->template get<ReturnType>();
21642 return std::forward<ValueType>(default_value);
21652 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21661 return ptr.get_checked(
this).template get<ValueType>();
21665 return default_value;
21674 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21677 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21686 return ptr.get_checked(
this).template get<ReturnType>();
21690 return std::forward<ValueType>(default_value);
21700 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21702 ValueType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
21704 return value(ptr.convert(), default_value);
21707 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21711 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21713 ReturnType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
21715 return value(ptr.convert(), std::forward<ValueType>(default_value));
21753 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21754 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21760 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
21763 IteratorType result = end();
21765 switch (m_data.m_type)
21767 case value_t::boolean:
21768 case value_t::number_float:
21769 case value_t::number_integer:
21770 case value_t::number_unsigned:
21771 case value_t::string:
21772 case value_t::binary:
21776 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
21781 AllocatorType<string_t> alloc;
21782 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
21783 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
21784 m_data.m_value.string =
nullptr;
21786 else if (is_binary())
21788 AllocatorType<binary_t> alloc;
21789 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
21790 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
21791 m_data.m_value.binary =
nullptr;
21794 m_data.m_type = value_t::null;
21795 assert_invariant();
21799 case value_t::object:
21801 result.m_it.object_iterator = m_data.m_value.object->erase(pos.m_it.object_iterator);
21805 case value_t::array:
21807 result.m_it.array_iterator = m_data.m_value.array->erase(pos.m_it.array_iterator);
21811 case value_t::null:
21812 case value_t::discarded:
21823 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21824 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21825 IteratorType
erase(IteratorType first, IteratorType last)
21830 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
21833 IteratorType result = end();
21835 switch (m_data.m_type)
21837 case value_t::boolean:
21838 case value_t::number_float:
21839 case value_t::number_integer:
21840 case value_t::number_unsigned:
21841 case value_t::string:
21842 case value_t::binary:
21845 || !last.m_it.primitive_iterator.is_end()))
21847 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
21852 AllocatorType<string_t> alloc;
21853 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.string);
21854 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.string, 1);
21855 m_data.m_value.string =
nullptr;
21857 else if (is_binary())
21859 AllocatorType<binary_t> alloc;
21860 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_data.m_value.binary);
21861 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_data.m_value.binary, 1);
21862 m_data.m_value.binary =
nullptr;
21865 m_data.m_type = value_t::null;
21866 assert_invariant();
21870 case value_t::object:
21872 result.m_it.object_iterator = m_data.m_value.object->erase(first.m_it.object_iterator,
21873 last.m_it.object_iterator);
21877 case value_t::array:
21879 result.m_it.array_iterator = m_data.m_value.array->erase(first.m_it.array_iterator,
21880 last.m_it.array_iterator);
21884 case value_t::null:
21885 case value_t::discarded:
21896 size_type erase_internal(KeyType && key)
21904 return m_data.m_value.object->erase(std::forward<KeyType>(key));
21909 size_type erase_internal(KeyType && key)
21917 const auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
21918 if (it != m_data.m_value.object->end())
21920 m_data.m_value.object->erase(it);
21934 return erase_internal(key);
21943 return erase_internal(std::forward<KeyType>(key));
21955 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
21958 m_data.m_value.array->erase(m_data.m_value.array->begin() +
static_cast<difference_type>(idx));
21979 auto result = end();
21983 result.m_it.object_iterator = m_data.m_value.object->find(key);
21993 auto result = cend();
21997 result.m_it.object_iterator = m_data.m_value.object->find(key);
22009 auto result = end();
22013 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
22025 auto result = cend();
22029 result.m_it.object_iterator = m_data.m_value.object->find(std::forward<KeyType>(key));
22040 return is_object() ? m_data.m_value.object->count(key) : 0;
22050 return is_object() ? m_data.m_value.object->count(std::forward<KeyType>(key)) : 0;
22055 bool contains(
const typename object_t::key_type& key)
const
22057 return is_object() && m_data.m_value.object->find(key) != m_data.m_value.object->end();
22066 return is_object() && m_data.m_value.object->find(std::forward<KeyType>(key)) != m_data.m_value.object->end();
22073 return ptr.contains(
this);
22076 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
22078 bool contains(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr)
const
22080 return ptr.contains(
this);
22097 result.set_begin();
22113 result.set_begin();
22193 return ref.items();
22204 return ref.items();
22211 return iteration_proxy<iterator>(*
this);
22216 iteration_proxy<const_iterator>
items() const noexcept
22218 return iteration_proxy<const_iterator>(*
this);
22234 switch (m_data.m_type)
22236 case value_t::null:
22242 case value_t::array:
22245 return m_data.m_value.array->empty();
22248 case value_t::object:
22251 return m_data.m_value.object->empty();
22254 case value_t::string:
22255 case value_t::boolean:
22256 case value_t::number_integer:
22257 case value_t::number_unsigned:
22258 case value_t::number_float:
22259 case value_t::binary:
22260 case value_t::discarded:
22273 switch (m_data.m_type)
22275 case value_t::null:
22281 case value_t::array:
22284 return m_data.m_value.array->size();
22287 case value_t::object:
22290 return m_data.m_value.object->size();
22293 case value_t::string:
22294 case value_t::boolean:
22295 case value_t::number_integer:
22296 case value_t::number_unsigned:
22297 case value_t::number_float:
22298 case value_t::binary:
22299 case value_t::discarded:
22312 switch (m_data.m_type)
22314 case value_t::array:
22317 return m_data.m_value.array->max_size();
22320 case value_t::object:
22323 return m_data.m_value.object->max_size();
22326 case value_t::null:
22327 case value_t::string:
22328 case value_t::boolean:
22329 case value_t::number_integer:
22330 case value_t::number_unsigned:
22331 case value_t::number_float:
22332 case value_t::binary:
22333 case value_t::discarded:
22355 switch (m_data.m_type)
22357 case value_t::number_integer:
22359 m_data.m_value.number_integer = 0;
22363 case value_t::number_unsigned:
22365 m_data.m_value.number_unsigned = 0;
22369 case value_t::number_float:
22371 m_data.m_value.number_float = 0.0;
22375 case value_t::boolean:
22377 m_data.m_value.boolean =
false;
22381 case value_t::string:
22383 m_data.m_value.string->clear();
22387 case value_t::binary:
22389 m_data.m_value.binary->clear();
22393 case value_t::array:
22395 m_data.m_value.array->clear();
22399 case value_t::object:
22401 m_data.m_value.object->clear();
22405 case value_t::null:
22406 case value_t::discarded:
22425 m_data.m_type = value_t::array;
22426 m_data.m_value = value_t::array;
22427 assert_invariant();
22431 const auto old_capacity = m_data.m_value.array->capacity();
22432 m_data.m_value.array->push_back(std::move(val));
22433 set_parent(m_data.m_value.array->back(), old_capacity);
22441 push_back(std::move(val));
22458 m_data.m_type = value_t::array;
22459 m_data.m_value = value_t::array;
22460 assert_invariant();
22464 const auto old_capacity = m_data.m_value.array->capacity();
22465 m_data.m_value.array->push_back(val);
22466 set_parent(m_data.m_value.array->back(), old_capacity);
22490 m_data.m_type = value_t::object;
22491 m_data.m_value = value_t::object;
22492 assert_invariant();
22496 auto res = m_data.m_value.object->insert(val);
22497 set_parent(res.first->second);
22512 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22514 basic_json&& key = init.begin()->moved_or_copied();
22515 push_back(
typename object_t::value_type(
22516 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22534 template<
class... Args>
22546 m_data.m_type = value_t::array;
22547 m_data.m_value = value_t::array;
22548 assert_invariant();
22552 const auto old_capacity = m_data.
m_value.array->capacity();
22553 m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
22554 return set_parent(m_data.m_value.array->back(), old_capacity);
22559 template<
class... Args>
22571 m_data.m_type = value_t::object;
22572 m_data.m_value = value_t::object;
22573 assert_invariant();
22577 auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
22578 set_parent(res.first->second);
22582 it.m_it.object_iterator = res.first;
22585 return {it, res.second};
22591 template<
typename... Args>
22597 auto insert_pos = std::distance(m_data.m_value.array->begin(), pos.m_it.array_iterator);
22598 m_data.m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22599 result.m_it.array_iterator = m_data.m_value.array->begin() + insert_pos;
22619 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22623 return insert_iterator(pos, val);
22633 return insert(pos, val);
22646 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22650 return insert_iterator(pos, cnt, val);
22669 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22675 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22680 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
22684 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22700 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22704 return insert_iterator(pos, ilist.begin(), ilist.end());
22720 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22726 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
22729 m_data.m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22736 update(j.
begin(), j.
end(), merge_objects);
22746 m_data.m_type = value_t::object;
22747 m_data.m_value.object = create<object_t>();
22748 assert_invariant();
22759 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22765 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
22768 for (
auto it = first; it != last; ++it)
22770 if (merge_objects && it.value().is_object())
22772 auto it2 = m_data.m_value.object->find(it.key());
22773 if (it2 != m_data.m_value.object->end())
22775 it2->second.update(it.value(),
true);
22779 m_data.m_value.object->operator[](it.key()) = it.value();
22780#if JSON_DIAGNOSTICS
22781 m_data.m_value.object->operator[](it.key()).m_parent =
this;
22789 std::is_nothrow_move_constructible<value_t>::value&&
22790 std::is_nothrow_move_assignable<value_t>::value&&
22791 std::is_nothrow_move_constructible<json_value>::value&&
22792 std::is_nothrow_move_assignable<json_value>::value
22795 std::swap(m_data.m_type, other.m_data.m_type);
22796 std::swap(m_data.m_value, other.m_data.m_value);
22799 other.set_parents();
22800 assert_invariant();
22806 std::is_nothrow_move_constructible<value_t>::value&&
22807 std::is_nothrow_move_assignable<value_t>::value&&
22808 std::is_nothrow_move_constructible<json_value>::value&&
22809 std::is_nothrow_move_assignable<json_value>::value
22823 swap(*(m_data.m_value.array), other);
22839 swap(*(m_data.m_value.object), other);
22855 swap(*(m_data.m_value.string), other);
22871 swap(*(m_data.m_value.binary), other);
22881 void swap(
typename binary_t::container_type& other)
22887 swap(*(m_data.m_value.binary), other);
22891 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
22906#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22907 const auto lhs_type = lhs.type(); \
22908 const auto rhs_type = rhs.type(); \
22910 if (lhs_type == rhs_type) \
22912 switch (lhs_type) \
22914 case value_t::array: \
22915 return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
22917 case value_t::object: \
22918 return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
22920 case value_t::null: \
22921 return (null_result); \
22923 case value_t::string: \
22924 return (*lhs.m_data.m_value.string) op (*rhs.m_data.m_value.string); \
22926 case value_t::boolean: \
22927 return (lhs.m_data.m_value.boolean) op (rhs.m_data.m_value.boolean); \
22929 case value_t::number_integer: \
22930 return (lhs.m_data.m_value.number_integer) op (rhs.m_data.m_value.number_integer); \
22932 case value_t::number_unsigned: \
22933 return (lhs.m_data.m_value.number_unsigned) op (rhs.m_data.m_value.number_unsigned); \
22935 case value_t::number_float: \
22936 return (lhs.m_data.m_value.number_float) op (rhs.m_data.m_value.number_float); \
22938 case value_t::binary: \
22939 return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
22941 case value_t::discarded: \
22943 return (unordered_result); \
22946 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22948 return static_cast<number_float_t>(lhs.m_data.m_value.number_integer) op rhs.m_data.m_value.number_float; \
22950 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22952 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_integer); \
22954 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22956 return static_cast<number_float_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_float; \
22958 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22960 return lhs.m_data.m_value.number_float op static_cast<number_float_t>(rhs.m_data.m_value.number_unsigned); \
22962 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22964 return static_cast<number_integer_t>(lhs.m_data.m_value.number_unsigned) op rhs.m_data.m_value.number_integer; \
22966 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22968 return lhs.m_data.m_value.number_integer op static_cast<number_integer_t>(rhs.m_data.m_value.number_unsigned); \
22970 else if(compares_unordered(lhs, rhs))\
22972 return (unordered_result);\
22975 return (default_result);
22990#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22993 static_cast<void>(inverse);
22999 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
23001 return compares_unordered(*
this, rhs, inverse);
23005#if JSON_HAS_THREE_WAY_COMPARISON
23008 bool operator==(const_reference rhs)
const noexcept
23011#pragma GCC diagnostic push
23012#pragma GCC diagnostic ignored "-Wfloat-equal"
23014 const_reference lhs = *
this;
23017#pragma GCC diagnostic pop
23023 template<
typename ScalarType>
23024 requires std::is_scalar_v<ScalarType>
23025 bool operator==(ScalarType rhs)
const noexcept
23032 bool operator!=(const_reference rhs)
const noexcept
23034 if (compares_unordered(rhs,
true))
23043 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
23045 const_reference lhs = *
this;
23049 std::partial_ordering::equivalent,
23050 std::partial_ordering::unordered,
23051 lhs_type <=> rhs_type)
23056 template<
typename ScalarType>
23057 requires std::is_scalar_v<ScalarType>
23058 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
23063#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
23070 bool operator<=(const_reference rhs)
const noexcept
23072 if (compares_unordered(rhs,
true))
23076 return !(rhs < *
this);
23081 template<
typename ScalarType>
23082 requires std::is_scalar_v<ScalarType>
23083 bool operator<=(ScalarType rhs)
const noexcept
23091 bool operator>=(const_reference rhs)
const noexcept
23093 if (compares_unordered(rhs,
true))
23097 return !(*
this < rhs);
23102 template<
typename ScalarType>
23103 requires std::is_scalar_v<ScalarType>
23104 bool operator>=(ScalarType rhs)
const noexcept
23112 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23115#pragma GCC diagnostic push
23116#pragma GCC diagnostic ignored "-Wfloat-equal"
23120#pragma GCC diagnostic pop
23126 template<
typename ScalarType,
typename std::enable_if<
23127 std::is_scalar<ScalarType>::value,
int>::type = 0>
23128 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23135 template<
typename ScalarType,
typename std::enable_if<
23136 std::is_scalar<ScalarType>::value,
int>::type = 0>
23137 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23144 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23146 if (compares_unordered(lhs, rhs,
true))
23150 return !(lhs == rhs);
23155 template<
typename ScalarType,
typename std::enable_if<
23156 std::is_scalar<ScalarType>::value,
int>::type = 0>
23157 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23164 template<
typename ScalarType,
typename std::enable_if<
23165 std::is_scalar<ScalarType>::value,
int>::type = 0>
23166 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23173 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23183 template<
typename ScalarType,
typename std::enable_if<
23184 std::is_scalar<ScalarType>::value,
int>::type = 0>
23185 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
23192 template<
typename ScalarType,
typename std::enable_if<
23193 std::is_scalar<ScalarType>::value,
int>::type = 0>
23194 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
23201 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
23203 if (compares_unordered(lhs, rhs,
true))
23207 return !(rhs < lhs);
23212 template<
typename ScalarType,
typename std::enable_if<
23213 std::is_scalar<ScalarType>::value,
int>::type = 0>
23214 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
23221 template<
typename ScalarType,
typename std::enable_if<
23222 std::is_scalar<ScalarType>::value,
int>::type = 0>
23223 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
23230 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
23233 if (compares_unordered(lhs, rhs))
23237 return !(lhs <= rhs);
23242 template<
typename ScalarType,
typename std::enable_if<
23243 std::is_scalar<ScalarType>::value,
int>::type = 0>
23244 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
23251 template<
typename ScalarType,
typename std::enable_if<
23252 std::is_scalar<ScalarType>::value,
int>::type = 0>
23253 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
23260 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
23262 if (compares_unordered(lhs, rhs,
true))
23266 return !(lhs < rhs);
23271 template<
typename ScalarType,
typename std::enable_if<
23272 std::is_scalar<ScalarType>::value,
int>::type = 0>
23273 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
23280 template<
typename ScalarType,
typename std::enable_if<
23281 std::is_scalar<ScalarType>::value,
int>::type = 0>
23282 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
23288#undef JSON_IMPLEMENT_OPERATOR
23301 friend std::ostream& operator<<(std::ostream& o,
const basic_json& j)
23304 const bool pretty_print = o.width() > 0;
23305 const auto indentation = pretty_print ? o.width() : 0;
23312 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23323 friend std::ostream& operator>>(
const basic_json& j, std::ostream& o)
23339 template<
typename InputType>
23342 const parser_callback_t cb =
nullptr,
23343 const bool allow_exceptions =
true,
23344 const bool ignore_comments =
false)
23347 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23353 template<
typename IteratorType>
23357 const parser_callback_t cb =
nullptr,
23358 const bool allow_exceptions =
true,
23359 const bool ignore_comments =
false)
23362 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23369 const parser_callback_t cb =
nullptr,
23370 const bool allow_exceptions =
true,
23371 const bool ignore_comments =
false)
23374 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23380 template<
typename InputType>
23381 static bool accept(InputType&& i,
23382 const bool ignore_comments =
false)
23384 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23389 template<
typename IteratorType>
23390 static bool accept(IteratorType first, IteratorType last,
23391 const bool ignore_comments =
false)
23393 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23399 const bool ignore_comments =
false)
23401 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23406 template <
typename InputType,
typename SAX>
23408 static
bool sax_parse(InputType&& i, SAX* sax,
23410 const
bool strict = true,
23411 const
bool ignore_comments = false)
23414 return format == input_format_t::json
23415 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23421 template<
class IteratorType,
class SAX>
23423 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23425 const
bool strict = true,
23426 const
bool ignore_comments = false)
23429 return format == input_format_t::json
23430 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23439 template <
typename SAX>
23442 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
23444 const
bool strict = true,
23445 const
bool ignore_comments = false)
23448 return format == input_format_t::json
23450 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23464 return operator>>(i, j);
23486 switch (m_data.m_type)
23488 case value_t::null:
23490 case value_t::object:
23492 case value_t::array:
23494 case value_t::string:
23496 case value_t::boolean:
23498 case value_t::binary:
23500 case value_t::discarded:
23501 return "discarded";
23502 case value_t::number_integer:
23503 case value_t::number_unsigned:
23504 case value_t::number_float:
23518 value_t m_type = value_t::null;
23521 json_value m_value = {};
23524 : m_type(v), m_value(v)
23531 m_value.array = create<array_t>(cnt, val);
23535 data(data&&) noexcept = default;
23536 data(const data&) noexcept = delete;
23537 data& operator=(data&&) noexcept = delete;
23538 data& operator=(const data&) noexcept = delete;
23542 m_value.destroy(m_type);
23548#if JSON_DIAGNOSTICS
23565 std::vector<std::uint8_t> result;
23566 to_cbor(j, result);
23574 binary_writer<std::uint8_t>(o).write_cbor(j);
23581 binary_writer<char>(o).write_cbor(j);
23588 std::vector<std::uint8_t> result;
23589 to_msgpack(j, result);
23597 binary_writer<std::uint8_t>(o).write_msgpack(j);
23604 binary_writer<char>(o).write_msgpack(j);
23610 const bool use_size =
false,
23611 const bool use_type =
false)
23613 std::vector<std::uint8_t> result;
23614 to_ubjson(j, result, use_size, use_type);
23621 const bool use_size =
false,
const bool use_type =
false)
23623 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
23629 const bool use_size =
false,
const bool use_type =
false)
23631 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23637 const bool use_size =
false,
23638 const bool use_type =
false)
23640 std::vector<std::uint8_t> result;
23641 to_bjdata(j, result, use_size, use_type);
23648 const bool use_size =
false,
const bool use_type =
false)
23650 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
23656 const bool use_size =
false,
const bool use_type =
false)
23658 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
23665 std::vector<std::uint8_t> result;
23666 to_bson(j, result);
23674 binary_writer<std::uint8_t>(o).write_bson(j);
23681 binary_writer<char>(o).write_bson(j);
23686 template<
typename InputType>
23689 const bool strict =
true,
23690 const bool allow_exceptions =
true,
23696 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23697 return res ? result :
basic_json(value_t::discarded);
23702 template<
typename IteratorType>
23705 const bool strict =
true,
23706 const bool allow_exceptions =
true,
23712 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23713 return res ? result :
basic_json(value_t::discarded);
23716 template<
typename T>
23720 const
bool strict = true,
23721 const
bool allow_exceptions = true,
23724 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23730 const
bool strict = true,
23731 const
bool allow_exceptions = true,
23738 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23739 return res ? result :
basic_json(value_t::discarded);
23744 template<
typename InputType>
23747 const bool strict =
true,
23748 const bool allow_exceptions =
true)
23753 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23754 return res ? result :
basic_json(value_t::discarded);
23759 template<
typename IteratorType>
23762 const bool strict =
true,
23763 const bool allow_exceptions =
true)
23768 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23769 return res ? result :
basic_json(value_t::discarded);
23772 template<
typename T>
23776 const
bool strict = true,
23777 const
bool allow_exceptions = true)
23779 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23785 const
bool strict = true,
23786 const
bool allow_exceptions = true)
23792 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23793 return res ? result :
basic_json(value_t::discarded);
23798 template<
typename InputType>
23801 const bool strict =
true,
23802 const bool allow_exceptions =
true)
23807 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23808 return res ? result :
basic_json(value_t::discarded);
23813 template<
typename IteratorType>
23816 const bool strict =
true,
23817 const bool allow_exceptions =
true)
23822 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23823 return res ? result :
basic_json(value_t::discarded);
23826 template<
typename T>
23830 const
bool strict = true,
23831 const
bool allow_exceptions = true)
23833 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23839 const
bool strict = true,
23840 const
bool allow_exceptions = true)
23846 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23847 return res ? result :
basic_json(value_t::discarded);
23852 template<
typename InputType>
23855 const bool strict =
true,
23856 const bool allow_exceptions =
true)
23861 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23862 return res ? result :
basic_json(value_t::discarded);
23867 template<
typename IteratorType>
23870 const bool strict =
true,
23871 const bool allow_exceptions =
true)
23876 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23877 return res ? result :
basic_json(value_t::discarded);
23882 template<
typename InputType>
23885 const bool strict =
true,
23886 const bool allow_exceptions =
true)
23891 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23892 return res ? result :
basic_json(value_t::discarded);
23897 template<
typename IteratorType>
23900 const bool strict =
true,
23901 const bool allow_exceptions =
true)
23906 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23907 return res ? result :
basic_json(value_t::discarded);
23910 template<
typename T>
23914 const
bool strict = true,
23915 const
bool allow_exceptions = true)
23917 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23923 const
bool strict = true,
23924 const
bool allow_exceptions = true)
23930 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23931 return res ? result :
basic_json(value_t::discarded);
23946 return ptr.get_unchecked(
this);
23949 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23953 return ptr.get_unchecked(
this);
23960 return ptr.get_unchecked(
this);
23963 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23967 return ptr.get_unchecked(
this);
23974 return ptr.get_checked(
this);
23977 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23981 return ptr.get_checked(
this);
23988 return ptr.get_checked(
this);
23991 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23995 return ptr.get_checked(
this);
24003 json_pointer::flatten(
"", *
this, result);
24011 return json_pointer::unflatten(*
this);
24029 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24031 const auto get_op = [](
const std::string & op)
24035 return patch_operations::add;
24037 if (op ==
"remove")
24039 return patch_operations::remove;
24041 if (op ==
"replace")
24043 return patch_operations::replace;
24047 return patch_operations::move;
24051 return patch_operations::copy;
24055 return patch_operations::test;
24058 return patch_operations::invalid;
24073 if (top_pointer != ptr)
24075 result.
at(top_pointer);
24079 const auto last_path = ptr.
back();
24084 switch (parent.
m_data.m_type)
24086 case value_t::null:
24087 case value_t::object:
24090 parent[last_path] = val;
24094 case value_t::array:
24096 if (last_path ==
"-")
24103 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
24107 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"), &parent));
24117 case value_t::string:
24118 case value_t::boolean:
24119 case value_t::number_integer:
24120 case value_t::number_unsigned:
24121 case value_t::number_float:
24122 case value_t::binary:
24123 case value_t::discarded:
24130 const auto operation_remove = [
this, & result](
json_pointer & ptr)
24133 const auto last_path = ptr.
back();
24141 auto it = parent.
find(last_path);
24154 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24161 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
24165 for (
const auto& val : json_patch)
24168 const auto get_value = [&val](
const std::string & op,
24169 const std::string & member,
24173 auto it = val.m_data.m_value.object->find(member);
24176 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24189 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
24199 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
24203 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24204 const auto path = get_value(op,
"path",
true).template get<std::string>();
24207 switch (get_op(op))
24209 case patch_operations::add:
24211 operation_add(ptr, get_value(
"add",
"value",
false));
24215 case patch_operations::remove:
24217 operation_remove(ptr);
24221 case patch_operations::replace:
24224 result.
at(ptr) = get_value(
"replace",
"value",
false);
24228 case patch_operations::move:
24230 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24240 operation_remove(from_ptr);
24241 operation_add(ptr, v);
24245 case patch_operations::copy:
24247 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24256 operation_add(ptr, v);
24260 case patch_operations::test:
24262 bool success =
false;
24267 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24283 case patch_operations::invalid:
24307 const std::string& path =
"")
24313 if (source == target)
24318 if (source.
type() != target.
type())
24323 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24328 switch (source.
type())
24330 case value_t::array:
24334 while (i < source.
size() && i < target.
size())
24337 auto temp_diff = diff(source[i], target[i],
detail::concat(path,
'/', std::to_string(i)));
24338 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24347 while (i < source.
size())
24351 result.
insert(result.
begin() + end_index,
object(
24354 {
"path", detail::concat(path,
'/', std::to_string(i))}
24360 while (i < target.
size())
24366 {
"value", target[i]}
24374 case value_t::object:
24377 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
24382 if (target.
find(it.key()) != target.
end())
24385 auto temp_diff = diff(it.value(), target[it.key()], path_key);
24386 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24393 {
"op",
"remove"}, {
"path", path_key}
24399 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
24401 if (source.
find(it.key()) == source.
end())
24407 {
"op",
"add"}, {
"path", path_key},
24408 {
"value", it.value()}
24416 case value_t::null:
24417 case value_t::string:
24418 case value_t::boolean:
24419 case value_t::number_integer:
24420 case value_t::number_unsigned:
24421 case value_t::number_float:
24422 case value_t::binary:
24423 case value_t::discarded:
24429 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24456 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
24458 if (it.value().is_null())
24464 operator[](it.key()).merge_patch(it.value());
24470 *
this = apply_patch;
24487inline namespace json_literals
24493#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24494 inline nlohmann::json
operator ""_json(
const char* s, std::size_t n)
24496 inline nlohmann::json
operator "" _json(
const char* s, std::size_t n)
24499 return nlohmann::json::parse(s, s + n);
24505#if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24530 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
24532 return nlohmann::detail::hash(j);
24538struct less< ::nlohmann::detail::value_t>
24545 ::nlohmann::detail::value_t rhs)
const noexcept
24547#if JSON_HAS_THREE_WAY_COMPARISON
24548 return std::is_lt(lhs <=> rhs);
24550 return ::nlohmann::detail::operator<(lhs, rhs);
24556#ifndef JSON_HAS_CPP_20
24561inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
24562 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24563 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24572#if JSON_USE_GLOBAL_UDLS
24573 #if !defined(JSON_HEDLEY_GCC_VERSION) || JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0)
24574 using nlohmann::literals::json_literals::operator
""_json;
24575 using nlohmann::literals::json_literals::operator
""_json_pointer;
24577 using nlohmann::literals::json_literals::operator
"" _json;
24578 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24594#if defined(__clang__)
24595 #pragma clang diagnostic pop
24600#undef JSON_INTERNAL_CATCH
24602#undef JSON_PRIVATE_UNLESS_TESTED
24603#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24604#undef NLOHMANN_BASIC_JSON_TPL
24605#undef JSON_EXPLICIT
24606#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24607#undef JSON_INLINE_VARIABLE
24608#undef JSON_NO_UNIQUE_ADDRESS
24609#undef JSON_DISABLE_ENUM_SERIALIZATION
24610#undef JSON_USE_GLOBAL_UDLS
24612#ifndef JSON_TEST_KEEP_MACROS
24615 #undef JSON_HAS_CPP_11
24616 #undef JSON_HAS_CPP_14
24617 #undef JSON_HAS_CPP_17
24618 #undef JSON_HAS_CPP_20
24619 #undef JSON_HAS_FILESYSTEM
24620 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24621 #undef JSON_HAS_THREE_WAY_COMPARISON
24622 #undef JSON_HAS_RANGES
24623 #undef JSON_HAS_STATIC_RTTI
24624 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24638#undef JSON_HEDLEY_ALWAYS_INLINE
24639#undef JSON_HEDLEY_ARM_VERSION
24640#undef JSON_HEDLEY_ARM_VERSION_CHECK
24641#undef JSON_HEDLEY_ARRAY_PARAM
24642#undef JSON_HEDLEY_ASSUME
24643#undef JSON_HEDLEY_BEGIN_C_DECLS
24644#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24645#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24646#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24647#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24648#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24649#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24650#undef JSON_HEDLEY_CLANG_HAS_WARNING
24651#undef JSON_HEDLEY_COMPCERT_VERSION
24652#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24653#undef JSON_HEDLEY_CONCAT
24654#undef JSON_HEDLEY_CONCAT3
24655#undef JSON_HEDLEY_CONCAT3_EX
24656#undef JSON_HEDLEY_CONCAT_EX
24657#undef JSON_HEDLEY_CONST
24658#undef JSON_HEDLEY_CONSTEXPR
24659#undef JSON_HEDLEY_CONST_CAST
24660#undef JSON_HEDLEY_CPP_CAST
24661#undef JSON_HEDLEY_CRAY_VERSION
24662#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24663#undef JSON_HEDLEY_C_DECL
24664#undef JSON_HEDLEY_DEPRECATED
24665#undef JSON_HEDLEY_DEPRECATED_FOR
24666#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24667#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24668#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24669#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24670#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24671#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24672#undef JSON_HEDLEY_DIAGNOSTIC_POP
24673#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24674#undef JSON_HEDLEY_DMC_VERSION
24675#undef JSON_HEDLEY_DMC_VERSION_CHECK
24676#undef JSON_HEDLEY_EMPTY_BASES
24677#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24678#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24679#undef JSON_HEDLEY_END_C_DECLS
24680#undef JSON_HEDLEY_FLAGS
24681#undef JSON_HEDLEY_FLAGS_CAST
24682#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24683#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24684#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24685#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24686#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24687#undef JSON_HEDLEY_GCC_HAS_FEATURE
24688#undef JSON_HEDLEY_GCC_HAS_WARNING
24689#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24690#undef JSON_HEDLEY_GCC_VERSION
24691#undef JSON_HEDLEY_GCC_VERSION_CHECK
24692#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24693#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24694#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24695#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24696#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24697#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24698#undef JSON_HEDLEY_GNUC_HAS_WARNING
24699#undef JSON_HEDLEY_GNUC_VERSION
24700#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24701#undef JSON_HEDLEY_HAS_ATTRIBUTE
24702#undef JSON_HEDLEY_HAS_BUILTIN
24703#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24704#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24705#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24706#undef JSON_HEDLEY_HAS_EXTENSION
24707#undef JSON_HEDLEY_HAS_FEATURE
24708#undef JSON_HEDLEY_HAS_WARNING
24709#undef JSON_HEDLEY_IAR_VERSION
24710#undef JSON_HEDLEY_IAR_VERSION_CHECK
24711#undef JSON_HEDLEY_IBM_VERSION
24712#undef JSON_HEDLEY_IBM_VERSION_CHECK
24713#undef JSON_HEDLEY_IMPORT
24714#undef JSON_HEDLEY_INLINE
24715#undef JSON_HEDLEY_INTEL_CL_VERSION
24716#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24717#undef JSON_HEDLEY_INTEL_VERSION
24718#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24719#undef JSON_HEDLEY_IS_CONSTANT
24720#undef JSON_HEDLEY_IS_CONSTEXPR_
24721#undef JSON_HEDLEY_LIKELY
24722#undef JSON_HEDLEY_MALLOC
24723#undef JSON_HEDLEY_MCST_LCC_VERSION
24724#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24725#undef JSON_HEDLEY_MESSAGE
24726#undef JSON_HEDLEY_MSVC_VERSION
24727#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24728#undef JSON_HEDLEY_NEVER_INLINE
24729#undef JSON_HEDLEY_NON_NULL
24730#undef JSON_HEDLEY_NO_ESCAPE
24731#undef JSON_HEDLEY_NO_RETURN
24732#undef JSON_HEDLEY_NO_THROW
24733#undef JSON_HEDLEY_NULL
24734#undef JSON_HEDLEY_PELLES_VERSION
24735#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24736#undef JSON_HEDLEY_PGI_VERSION
24737#undef JSON_HEDLEY_PGI_VERSION_CHECK
24738#undef JSON_HEDLEY_PREDICT
24739#undef JSON_HEDLEY_PRINTF_FORMAT
24740#undef JSON_HEDLEY_PRIVATE
24741#undef JSON_HEDLEY_PUBLIC
24742#undef JSON_HEDLEY_PURE
24743#undef JSON_HEDLEY_REINTERPRET_CAST
24744#undef JSON_HEDLEY_REQUIRE
24745#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24746#undef JSON_HEDLEY_REQUIRE_MSG
24747#undef JSON_HEDLEY_RESTRICT
24748#undef JSON_HEDLEY_RETURNS_NON_NULL
24749#undef JSON_HEDLEY_SENTINEL
24750#undef JSON_HEDLEY_STATIC_ASSERT
24751#undef JSON_HEDLEY_STATIC_CAST
24752#undef JSON_HEDLEY_STRINGIFY
24753#undef JSON_HEDLEY_STRINGIFY_EX
24754#undef JSON_HEDLEY_SUNPRO_VERSION
24755#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24756#undef JSON_HEDLEY_TINYC_VERSION
24757#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24758#undef JSON_HEDLEY_TI_ARMCL_VERSION
24759#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24760#undef JSON_HEDLEY_TI_CL2000_VERSION
24761#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24762#undef JSON_HEDLEY_TI_CL430_VERSION
24763#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24764#undef JSON_HEDLEY_TI_CL6X_VERSION
24765#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24766#undef JSON_HEDLEY_TI_CL7X_VERSION
24767#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24768#undef JSON_HEDLEY_TI_CLPRU_VERSION
24769#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24770#undef JSON_HEDLEY_TI_VERSION
24771#undef JSON_HEDLEY_TI_VERSION_CHECK
24772#undef JSON_HEDLEY_UNAVAILABLE
24773#undef JSON_HEDLEY_UNLIKELY
24774#undef JSON_HEDLEY_UNPREDICTABLE
24775#undef JSON_HEDLEY_UNREACHABLE
24776#undef JSON_HEDLEY_UNREACHABLE_RETURN
24777#undef JSON_HEDLEY_VERSION
24778#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24779#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24780#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24781#undef JSON_HEDLEY_VERSION_ENCODE
24782#undef JSON_HEDLEY_WARNING
24783#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24784#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24785#undef JSON_HEDLEY_FALL_THROUGH
namespace for Niels Lohmann
定义 json.hpp:19425
constexpr bool is_string() const noexcept
return whether value is a string
定义 json.hpp:20697
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
定义 json.hpp:21930
reference operator[](KeyType &&key)
access specified object element
定义 json.hpp:21498
size_type size() const noexcept
returns the number of elements
定义 json.hpp:22271
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
定义 json.hpp:23704
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
定义 json.hpp:23636
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
定义 json.hpp:21070
const_iterator end() const noexcept
returns an iterator to one past the last element
定义 json.hpp:22128
reference back()
access the last element
定义 json.hpp:21734
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
定义 json.hpp:20161
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
定义 json.hpp:22144
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
定义 json.hpp:24296
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
定义 json.hpp:23484
const_reference front() const
access the first element
定义 json.hpp:21727
constexpr bool is_array() const noexcept
return whether value is an array
定义 json.hpp:20690
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
定义 json.hpp:22788
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
定义 json.hpp:21678
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
定义 json.hpp:22047
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
定义 json.hpp:19556
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
定义 json.hpp:23655
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
定义 json.hpp:20662
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
定义 json.hpp:19560
data(size_type cnt, const basic_json &val)
定义 json.hpp:23528
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
定义 json.hpp:23899
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
定义 json.hpp:23647
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
定义 json.hpp:23944
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
定义 json.hpp:19551
std::size_t size_type
a type to represent container sizes
定义 json.hpp:19543
constexpr bool is_structured() const noexcept
return whether type is structured
定义 json.hpp:20634
const_reference operator[](KeyType &&key) const
access specified object element
定义 json.hpp:21522
void swap(binary_t &other)
exchanges the values
定义 json.hpp:22865
ReferenceType get_ref()
get a reference value (implicit)
定义 json.hpp:21160
size_type max_size() const noexcept
returns the maximum possible number of elements
定义 json.hpp:22310
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
定义 json.hpp:22734
ReferenceType get_ref() const
get a reference value (implicit)
定义 json.hpp:21171
constexpr bool is_discarded() const noexcept
return whether value is discarded
定义 json.hpp:20711
reference operator+=(initializer_list_t init)
add an object to an object
定义 json.hpp:22526
void push_back(basic_json &&val)
add an object to an array
定义 json.hpp:22414
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
定义 json.hpp:21467
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
定义 json.hpp:22216
const_reference back() const
access the last element
定义 json.hpp:21743
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
定义 json.hpp:21825
reference operator+=(const basic_json &val)
add an object to an array
定义 json.hpp:22471
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&//NOLINT(cppcoreguidelines-noexcept-swap, performance-noexcept-swap) std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
定义 json.hpp:22805
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
定义 json.hpp:23800
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
定义 json.hpp:20298
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
定义 json.hpp:22638
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
定义 json.hpp:23884
static allocator_type get_allocator()
returns the allocator associated with the container
定义 json.hpp:19566
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
定义 json.hpp:19691
reference at(KeyType &&key)
access specified object element with bounds checking
定义 json.hpp:21330
iterator end() noexcept
returns an iterator to one past the last element
定义 json.hpp:22119
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
定义 json.hpp:20669
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
定义 json.hpp:22741
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
定义 json.hpp:23663
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
定义 json.hpp:22151
data m_data
定义 json.hpp:23546
void push_back(initializer_list_t init)
add an object to an object
定义 json.hpp:22510
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
定义 json.hpp:20128
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
定义 json.hpp:20339
ValueType & get_to(ValueType &v) const
定义 json.hpp:21137
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
定义 json.hpp:23602
iterator begin() noexcept
returns an iterator to the first element
定义 json.hpp:22094
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
定义 json.hpp:21577
const_iterator cend() const noexcept
returns an iterator to one past the last element
定义 json.hpp:22135
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
定义 json.hpp:23854
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
定义 json.hpp:23986
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
定义 json.hpp:20309
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
定义 json.hpp:20149
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
定义 json.hpp:23688
basic_json flatten() const
return flattened JSON value
定义 json.hpp:24000
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
定义 json.hpp:23815
size_type erase(KeyType &&key)
remove element from a JSON object given a key
定义 json.hpp:21941
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
定义 json.hpp:19667
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
定义 json.hpp:19659
const binary_t & get_binary() const
get a binary value
定义 json.hpp:21242
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
定义 json.hpp:22658
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
定义 json.hpp:24025
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
定义 json.hpp:21630
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
定义 json.hpp:24306
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
定义 json.hpp:23958
value_type & reference
the type of an element reference
定义 json.hpp:19536
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
定义 json.hpp:19500
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
定义 json.hpp:22064
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
定义 json.hpp:23572
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
定义 json.hpp:23679
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
定义 json.hpp:21977
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
定义 json.hpp:20287
const_reference at(KeyType &&key) const
access specified object element with bounds checking
定义 json.hpp:21368
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
定义 json.hpp:19574
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
定义 json.hpp:20346
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
定义 json.hpp:21991
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
定义 json.hpp:23563
IteratorType erase(IteratorType pos)
remove element given an iterator
定义 json.hpp:21755
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
定义 json.hpp:22611
NumberFloatType number_float_t
a type for a number (floating-point)
定义 json.hpp:19687
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
定义 json.hpp:21552
AllocatorType< basic_json > allocator_type
the allocator type
定义 json.hpp:19546
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
定义 json.hpp:19549
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
定义 json.hpp:20598
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
定义 json.hpp:24448
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
定义 json.hpp:21124
reference operator[](T *key)
定义 json.hpp:21483
reference at(size_type idx)
access specified array element with bounds checking
定义 json.hpp:21264
iterator find(KeyType &&key)
find an element in a JSON object
定义 json.hpp:22007
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
定义 json.hpp:20676
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
定义 json.hpp:22158
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
定义 json.hpp:23609
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
定义 json.hpp:23972
BooleanType boolean_t
a type for a boolean
定义 json.hpp:19675
detail::value_t value_t
定义 json.hpp:19490
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
定义 json.hpp:19654
reference operator+=(const typename object_t::value_type &val)
add an object to an object
定义 json.hpp:22502
const_iterator cbegin() const noexcept
returns a const iterator to the first element
定义 json.hpp:22110
reference operator[](typename object_t::key_type key)
access specified object element
定义 json.hpp:21445
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
定义 json.hpp:20882
~basic_json() noexcept
destructor
定义 json.hpp:20580
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
定义 json.hpp:22179
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
定义 json.hpp:20228
void swap(typename binary_t::container_type &other)
exchanges the values
定义 json.hpp:22881
binary_t & get_binary()
get a binary value
定义 json.hpp:21230
const_iterator begin() const noexcept
returns an iterator to the first element
定义 json.hpp:22103
constexpr bool is_number() const noexcept
return whether value is a number
定义 json.hpp:20655
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
定义 json.hpp:22709
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
定义 json.hpp:23746
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
定义 json.hpp:21111
const_reference operator[](T *key) const
定义 json.hpp:21489
data(const value_t v)
定义 json.hpp:23523
reference operator[](size_type idx)
access specified array element
定义 json.hpp:21386
basic_json(const JsonRef &ref)
定义 json.hpp:20467
JSONSerializer< T, SFINAE > json_serializer
定义 json.hpp:19494
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
定义 json.hpp:20557
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
定义 json.hpp:23628
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
定义 json.hpp:21148
NumberIntegerType number_integer_t
a type for a number (integer)
定义 json.hpp:19679
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
定义 json.hpp:20871
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
定义 json.hpp:21348
constexpr bool is_binary() const noexcept
return whether value is a binary array
定义 json.hpp:20704
void swap(object_t &other)
exchanges the values
定义 json.hpp:22833
basic_json unflatten() const
unflatten a previously flattened JSON value
定义 json.hpp:24009
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
定义 json.hpp:22689
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
定义 json.hpp:20320
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
定义 json.hpp:22209
bool empty() const noexcept
checks whether the container is empty.
定义 json.hpp:22232
void swap(array_t &other)
exchanges the values
定义 json.hpp:22817
void erase(const size_type idx)
remove element from a JSON array given an index
定义 json.hpp:21948
reference operator+=(basic_json &&val)
add an object to an array
定义 json.hpp:22439
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
定义 json.hpp:22071
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
定义 json.hpp:20620
reference emplace_back(Args &&... args)
add an object to an array
定义 json.hpp:22535
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
定义 json.hpp:21653
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
定义 json.hpp:20331
StringType string_t
a type for a string
定义 json.hpp:19671
friend class ::nlohmann::detail::parser
定义 json.hpp:19435
void push_back(const basic_json &val)
add an object to an array
定义 json.hpp:22447
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
定义 json.hpp:21603
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
定义 json.hpp:21310
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
定义 json.hpp:23869
json_value m_value
the value of the current element
定义 json.hpp:23521
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
定义 json.hpp:22172
constexpr bool is_boolean() const noexcept
return whether value is a boolean
定义 json.hpp:20648
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
定义 json.hpp:22037
reference front()
access the first element
定义 json.hpp:21720
constexpr bool is_primitive() const noexcept
return whether type is primitive
定义 json.hpp:20627
constexpr bool is_null() const noexcept
return whether value is null
定义 json.hpp:20641
void clear() noexcept
clears the contents
定义 json.hpp:22353
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
定义 json.hpp:23620
basic_json(basic_json &&other) noexcept
move constructor
定义 json.hpp:20540
iter_impl< basic_json > iterator
an iterator for a basic_json container
定义 json.hpp:19554
basic_json(const value_t v)
create an empty value with a given type
定义 json.hpp:20141
const_reference operator[](size_type idx) const
access specified array element
定义 json.hpp:21432
std::ptrdiff_t difference_type
a type to represent differences between iterators
定义 json.hpp:19541
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
定义 json.hpp:22631
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
定义 json.hpp:22165
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
定义 json.hpp:19683
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
定义 json.hpp:23469
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
定义 json.hpp:23586
void swap(string_t &other)
exchanges the values
定义 json.hpp:22849
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
定义 json.hpp:20175
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
定义 json.hpp:19558
const_reference at(size_type idx) const
access specified array element with bounds checking
定义 json.hpp:21287
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
定义 json.hpp:19695
basic_json(const basic_json &other)
copy constructor
定义 json.hpp:20471
void push_back(const typename object_t::value_type &val)
add an object to an object
定义 json.hpp:22479
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
定义 json.hpp:22560
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
定义 json.hpp:23579
constexpr bool is_object() const noexcept
return whether value is an object
定义 json.hpp:20683
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
定义 json.hpp:23595
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
定义 json.hpp:23761
iterator insert_iterator(const_iterator pos, Args &&... args)
定义 json.hpp:22592
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
定义 json.hpp:20358
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
定义 json.hpp:22055
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
定义 json.hpp:23672
const_iterator find(KeyType &&key) const
find an element in a JSON object
定义 json.hpp:22023
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer
定义 json.hpp:19492
an internal type for a backed binary type
定义 json.hpp:5915
bool operator!=(const byte_container_with_subtype &rhs) const
定义 json.hpp:5955
byte_container_with_subtype() noexcept(noexcept(container_type()))
定义 json.hpp:5921
std::uint64_t subtype_type
定义 json.hpp:5918
bool operator==(const byte_container_with_subtype &rhs) const
定义 json.hpp:5949
BinaryType container_type
定义 json.hpp:5917
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
定义 json.hpp:5943
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
定义 json.hpp:5931
constexpr subtype_type subtype() const noexcept
return the binary subtype
定义 json.hpp:5970
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
定义 json.hpp:5936
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
定义 json.hpp:5977
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
定义 json.hpp:5926
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
定义 json.hpp:5962
void clear_subtype() noexcept
clears the binary subtype
定义 json.hpp:5984
deserialization of CBOR, MessagePack, and UBJSON values
定义 json.hpp:9236
binary_reader(const binary_reader &)=delete
binary_reader(binary_reader &&)=default
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
定义 json.hpp:9252
binary_reader & operator=(const binary_reader &)=delete
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
定义 json.hpp:9273
binary_reader & operator=(binary_reader &&)=default
serialization to CBOR and MessagePack values
定义 json.hpp:15103
void write_bson(const BasicJsonType &j)
定义 json.hpp:15123
static constexpr CharType to_char_type(std::uint8_t x) noexcept
定义 json.hpp:16858
static CharType to_char_type(std::uint8_t x) noexcept
定义 json.hpp:16865
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
定义 json.hpp:15114
static constexpr CharType to_char_type(InputCharType x) noexcept
定义 json.hpp:16887
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
定义 json.hpp:15802
void write_msgpack(const BasicJsonType &j)
定义 json.hpp:15476
void write_cbor(const BasicJsonType &j)
定义 json.hpp:15152
general exception of the basic_json class
定义 json.hpp:4396
const int id
the id of the exception
定义 json.hpp:4405
static std::string diagnostics(std::nullptr_t)
定义 json.hpp:4416
static std::string name(const std::string &ename, int id_)
定义 json.hpp:4411
const char * what() const noexcept override
returns the explanatory string
定义 json.hpp:4399
static std::string diagnostics(const BasicJsonType *leaf_element)
定义 json.hpp:4422
exception indicating errors with iterators
定义 json.hpp:4547
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
定义 json.hpp:4550
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
定义 json.hpp:12940
iter_impl operator+(difference_type i) const
add to iterator
定义 json.hpp:13514
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
定义 json.hpp:13077
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
定义 json.hpp:13459
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
定义 json.hpp:13067
bool operator<(const iter_impl &other) const
comparison: smaller
定义 json.hpp:13406
bool operator<=(const iter_impl &other) const
comparison: less than or equal
定义 json.hpp:13441
iter_impl & operator-=(difference_type i)
subtract from iterator
定义 json.hpp:13505
iter_impl & operator--()
pre-decrement (–it)
定义 json.hpp:13320
const object_t::key_type & key() const
return the key of an object iterator
定义 json.hpp:13614
bool operator==(const IterImpl &other) const
comparison: equal
定义 json.hpp:13361
iter_impl operator++(int) &
post-increment (it++)
定义 json.hpp:13258
iter_impl & operator+=(difference_type i)
add to iterator
定义 json.hpp:13468
reference operator[](difference_type n) const
access to successor
定义 json.hpp:13576
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
定义 json.hpp:12972
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
定义 json.hpp:12970
pointer operator->() const
dereference the iterator
定义 json.hpp:13216
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
定义 json.hpp:13639
difference_type operator-(const iter_impl &other) const
return difference
定义 json.hpp:13547
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
定义 json.hpp:12965
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
定义 json.hpp:13525
reference value() const
return the value of an iterator
定义 json.hpp:13630
bool operator>(const iter_impl &other) const
comparison: greater than
定义 json.hpp:13450
iter_impl & operator++()
pre-increment (++it)
定义 json.hpp:13269
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
定义 json.hpp:12968
reference operator*() const
return a reference to the value pointed to by the iterator
定义 json.hpp:13172
iter_impl operator-(difference_type i) const
subtract from iterator
定义 json.hpp:13536
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
定义 json.hpp:12976
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
定义 json.hpp:13052
bool operator!=(const IterImpl &other) const
comparison: not equal
定义 json.hpp:13397
iter_impl operator--(int) &
post-decrement (it–)
定义 json.hpp:13309
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
定义 json.hpp:13042
void set_end() noexcept
set the iterator past the last value
定义 json.hpp:13133
iteration_proxy_value operator++(int) &
定义 json.hpp:5266
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
定义 json.hpp:5275
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
定义 json.hpp:5281
std::ptrdiff_t difference_type
定义 json.hpp:5212
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
定义 json.hpp:5233
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
定义 json.hpp:5258
iteration_proxy_value()=default
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
定义 json.hpp:5323
const string_type & key() const
return key of the iterator
定义 json.hpp:5287
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
std::input_iterator_tag iterator_category
定义 json.hpp:5216
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
定义 json.hpp:5217
proxy class for the items() function
定义 json.hpp:12919
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
定义 json.hpp:5356
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
定义 json.hpp:5340
iteration_proxy & operator=(iteration_proxy const &)=default
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
定义 json.hpp:14852
json_ref(value_type &&value)
定义 json.hpp:14848
value_type const & operator*() const
定义 json.hpp:14883
value_type const * operator->() const
定义 json.hpp:14888
json_ref(std::initializer_list< json_ref > init)
定义 json.hpp:14856
json_ref(Args &&... args)
定义 json.hpp:14863
value_type moved_or_copied() const
定义 json.hpp:14874
BasicJsonType value_type
定义 json.hpp:14846
a template for a reverse iterator class
定义 json.hpp:13693
json_reverse_iterator operator++(int) &
post-increment (it++)
定义 json.hpp:13709
json_reverse_iterator operator--(int) &
post-decrement (it–)
定义 json.hpp:13721
json_reverse_iterator & operator++()
pre-increment (++it)
定义 json.hpp:13715
std::ptrdiff_t difference_type
定义 json.hpp:13695
json_reverse_iterator & operator+=(difference_type i)
add to iterator
定义 json.hpp:13733
reference operator[](difference_type n) const
access to successor
定义 json.hpp:13757
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
定义 json.hpp:13763
difference_type operator-(const json_reverse_iterator &other) const
return difference
定义 json.hpp:13751
typename Base::reference reference
the reference type for the pointed-to element
定义 json.hpp:13699
reference value() const
return the value of an iterator
定义 json.hpp:13770
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
定义 json.hpp:13706
json_reverse_iterator & operator--()
pre-decrement (–it)
定义 json.hpp:13727
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
定义 json.hpp:13697
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
定义 json.hpp:13745
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
定义 json.hpp:13702
json_reverse_iterator operator+(difference_type i) const
add to iterator
定义 json.hpp:13739
typename BasicJsonType::number_unsigned_t number_unsigned_t
定义 json.hpp:7317
bool end_object()
定义 json.hpp:7367
bool start_object(std::size_t=static_cast< std::size_t >(-1))
定义 json.hpp:7357
bool binary(binary_t &)
定义 json.hpp:7352
bool number_integer(number_integer_t)
定义 json.hpp:7332
bool start_array(std::size_t=static_cast< std::size_t >(-1))
定义 json.hpp:7372
bool boolean(bool)
定义 json.hpp:7327
bool null()
定义 json.hpp:7322
bool end_array()
定义 json.hpp:7377
bool number_unsigned(number_unsigned_t)
定义 json.hpp:7337
bool string(string_t &)
定义 json.hpp:7347
typename BasicJsonType::binary_t binary_t
定义 json.hpp:7320
bool number_float(number_float_t, const string_t &)
定义 json.hpp:7342
bool parse_error(std::size_t, const std::string &, const detail::exception &)
定义 json.hpp:7382
bool key(string_t &)
定义 json.hpp:7362
typename BasicJsonType::number_integer_t number_integer_t
定义 json.hpp:7316
typename BasicJsonType::number_float_t number_float_t
定义 json.hpp:7318
typename BasicJsonType::string_t string_t
定义 json.hpp:7319
bool boolean(bool val)
定义 json.hpp:7038
bool parse_error(std::size_t, const std::string &, const Exception &ex)
定义 json.hpp:7195
typename BasicJsonType::string_t string_t
定义 json.hpp:7012
bool number_float(number_float_t val, const string_t &)
定义 json.hpp:7056
constexpr bool is_errored() const
定义 json.hpp:7207
bool string(string_t &val)
定义 json.hpp:7062
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
定义 json.hpp:7010
typename BasicJsonType::binary_t binary_t
定义 json.hpp:7013
bool start_object(std::size_t len)
定义 json.hpp:7074
bool start_array(std::size_t len)
定义 json.hpp:7145
typename BasicJsonType::number_integer_t number_integer_t
定义 json.hpp:7009
bool end_array()
定义 json.hpp:7162
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool key(string_t &val)
定义 json.hpp:7092
bool end_object()
定义 json.hpp:7109
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
定义 json.hpp:7015
typename BasicJsonType::parser_callback_t parser_callback_t
定义 json.hpp:7014
bool null()
定义 json.hpp:7032
bool number_unsigned(number_unsigned_t val)
定义 json.hpp:7050
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
定义 json.hpp:7017
typename BasicJsonType::number_float_t number_float_t
定义 json.hpp:7011
bool number_integer(number_integer_t val)
定义 json.hpp:7044
bool binary(binary_t &val)
定义 json.hpp:7068
SAX implementation to create a JSON value from SAX events
定义 json.hpp:6824
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
定义 json.hpp:6878
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
定义 json.hpp:6837
bool parse_error(std::size_t, const std::string &, const Exception &ex)
定义 json.hpp:6945
bool null()
定义 json.hpp:6848
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
定义 json.hpp:6829
bool start_object(std::size_t len)
定义 json.hpp:6890
typename BasicJsonType::number_unsigned_t number_unsigned_t
定义 json.hpp:6827
bool number_unsigned(number_unsigned_t val)
定义 json.hpp:6866
bool number_integer(number_integer_t val)
定义 json.hpp:6860
typename BasicJsonType::number_integer_t number_integer_t
定义 json.hpp:6826
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
定义 json.hpp:6884
json_sax_dom_parser(json_sax_dom_parser &&)=default
bool boolean(bool val)
定义 json.hpp:6854
bool end_array()
定义 json.hpp:6934
bool number_float(number_float_t val, const string_t &)
定义 json.hpp:6872
bool end_object()
定义 json.hpp:6912
constexpr bool is_errored() const
定义 json.hpp:6957
typename BasicJsonType::binary_t binary_t
定义 json.hpp:6830
typename BasicJsonType::number_float_t number_float_t
定义 json.hpp:6828
bool start_array(std::size_t len)
定义 json.hpp:6922
bool key(string_t &val)
定义 json.hpp:6902
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
定义 json.hpp:7458
token_type
token types for the parser
定义 json.hpp:7435
lexical analysis
定义 json.hpp:7508
bool skip_bom()
skip the UTF-8 byte order mark
定义 json.hpp:8882
void skip_whitespace()
定义 json.hpp:8896
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
定义 json.hpp:7519
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
定义 json.hpp:8869
std::string get_token_string() const
定义 json.hpp:8844
constexpr number_integer_t get_number_integer() const noexcept
return integer value
定义 json.hpp:8808
constexpr position_t get_position() const noexcept
return position of last read token
定义 json.hpp:8836
token_type scan()
定义 json.hpp:8905
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
定义 json.hpp:8814
typename lexer_base< BasicJsonType >::token_type token_type
定义 json.hpp:7517
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
lexer & operator=(lexer &)=delete
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
定义 json.hpp:8826
constexpr number_float_t get_number_float() const noexcept
return floating-point value
定义 json.hpp:8820
exception indicating other library errors
定义 json.hpp:4599
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
定义 json.hpp:4602
exception indicating access out of the defined range
定义 json.hpp:4582
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
定义 json.hpp:4585
output_adapter(StringType &s)
定义 json.hpp:15072
output_adapter(std::basic_ostream< CharType > &s)
定义 json.hpp:15068
output_adapter(std::vector< CharType, AllocatorType > &vec)
定义 json.hpp:15064
output adapter for output streams
定义 json.hpp:15013
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
定义 json.hpp:15015
void write_character(CharType c) override
定义 json.hpp:15019
output adapter for basic_string
定义 json.hpp:15038
void write_character(CharType c) override
定义 json.hpp:15044
output_string_adapter(StringType &s) noexcept
定义 json.hpp:15040
output adapter for byte vectors
定义 json.hpp:14988
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
定义 json.hpp:14990
void write_character(CharType c) override
定义 json.hpp:14994
exception indicating a parse error
定义 json.hpp:4494
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
定义 json.hpp:4506
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
定义 json.hpp:4514
const std::size_t byte
byte index of the parse error
定义 json.hpp:4531
syntax analysis
定义 json.hpp:12253
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
定义 json.hpp:12263
void parse(const bool strict, BasicJsonType &result)
public parser interface
定义 json.hpp:12285
bool accept(const bool strict=true)
public accept interface
定义 json.hpp:12345
bool sax_parse(SAX *sax, const bool strict=true)
定义 json.hpp:12353
primitive_iterator_t & operator++() noexcept
定义 json.hpp:12819
primitive_iterator_t & operator-=(difference_type n) noexcept
定义 json.hpp:12851
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
定义 json.hpp:12786
primitive_iterator_t & operator--() noexcept
定义 json.hpp:12832
void set_end() noexcept
set iterator to a defined past the end
定义 json.hpp:12780
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
定义 json.hpp:12802
constexpr bool is_end() const noexcept
return whether the iterator is at end
定义 json.hpp:12792
primitive_iterator_t operator++(int) &noexcept
定义 json.hpp:12825
primitive_iterator_t & operator+=(difference_type n) noexcept
定义 json.hpp:12845
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
定义 json.hpp:12797
constexpr difference_type get_value() const noexcept
定义 json.hpp:12768
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
定义 json.hpp:12814
primitive_iterator_t operator+(difference_type n) noexcept
定义 json.hpp:12807
void set_begin() noexcept
set iterator to a defined beginning
定义 json.hpp:12774
primitive_iterator_t operator--(int) &noexcept
定义 json.hpp:12838
std::array< char, 512 > string_buffer
string buffer
定义 json.hpp:19008
std::uint8_t state
定义 json.hpp:18426
std::size_t bytes_after_last_accept
定义 json.hpp:18430
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
定义 json.hpp:18099
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
定义 json.hpp:18424
std::size_t undumped_chars
定义 json.hpp:18431
const char thousands_sep
the locale's thousand separator character
定义 json.hpp:19003
const char decimal_point
the locale's decimal point character
定义 json.hpp:19005
serializer & operator=(const serializer &)=delete
const error_handler_t error_handler
error_handler how to react on decoding errors
定义 json.hpp:19016
string_t indent_string
the indentation string
定义 json.hpp:19013
const std::lconv * loc
the locale
定义 json.hpp:19001
serializer & operator=(serializer &&)=delete
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
定义 json.hpp:18998
const char indent_char
the indentation character
定义 json.hpp:19011
std::size_t bytes
定义 json.hpp:18427
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
定义 json.hpp:18139
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
定义 json.hpp:4565
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
定义 json.hpp:4568
JSON Pointer defines a string syntax for identifying a specific value within a JSON document
定义 json.hpp:13865
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
定义 json.hpp:13960
typename string_t_helper< RefStringType >::type string_t
定义 json.hpp:13887
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
定义 json.hpp:13967
friend bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for equality
定义 json.hpp:14760
json_pointer(const string_t &s="")
create JSON pointer
定义 json.hpp:13891
bool empty() const noexcept
return whether pointer points to the root document
定义 json.hpp:14026
void pop_back()
remove last reference token
定义 json.hpp:13988
string_t to_string() const
return a string representation of the JSON pointer
定义 json.hpp:13897
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
定义 json.hpp:13945
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
定义 json.hpp:14019
friend bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointer for less-than
定义 json.hpp:14810
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
定义 json.hpp:13927
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
定义 json.hpp:13952
json_pointer parent_pointer() const
returns the parent of this JSON pointer
定义 json.hpp:13974
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
定义 json.hpp:13937
friend class json_pointer
定义 json.hpp:13871
const string_t & back() const
return last reference token
定义 json.hpp:14000
friend bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
compares two JSON pointers for inequality
定义 json.hpp:14785
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
定义 json.hpp:13918
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
定义 json.hpp:14012
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
定义 json.hpp:5402
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
定义 json.hpp:2620
#define JSON_HEDLEY_CONST
定义 json.hpp:1842
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
定义 json.hpp:1126
#define JSON_INLINE_VARIABLE
定义 json.hpp:2523
#define JSON_HEDLEY_WARN_UNUSED_RESULT
定义 json.hpp:1472
#define JSON_PRIVATE_UNLESS_TESTED
定义 json.hpp:2583
#define NLOHMANN_JSON_VERSION_PATCH
定义 json.hpp:94
#define JSON_HEDLEY_LIKELY(expr)
定义 json.hpp:1737
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
定义 json.hpp:14760
#define JSON_HEDLEY_NON_NULL(...)
定义 json.hpp:1630
#define JSON_INTERNAL_CATCH(exception)
定义 json.hpp:2550
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
定义 json.hpp:24480
#define JSON_HEDLEY_RETURNS_NON_NULL
定义 json.hpp:2071
#define JSON_CATCH(exception)
定义 json.hpp:2549
#define JSON_ASSERT(x)
定义 json.hpp:2576
#define JSON_THROW(exception)
定义 json.hpp:2547
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
定义 json.hpp:101
#define NLOHMANN_JSON_VERSION_MAJOR
定义 json.hpp:92
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
定义 json.hpp:14810
#define NLOHMANN_BASIC_JSON_TPL
定义 json.hpp:2630
#define JSON_HEDLEY_UNLIKELY(expr)
定义 json.hpp:1738
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
定义 json.hpp:12143
#define JSON_TRY
定义 json.hpp:2548
#define NLOHMANN_JSON_NAMESPACE_END
定义 json.hpp:168
#define JSON_NO_UNIQUE_ADDRESS
定义 json.hpp:2529
#define NLOHMANN_JSON_VERSION_MINOR
定义 json.hpp:93
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
定义 json.hpp:2810
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
定义 json.hpp:14785
#define NLOHMANN_JSON_NAMESPACE_BEGIN
定义 json.hpp:158
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
定义 json.hpp:12140
#define JSON_HEDLEY_DIAGNOSTIC_POP
定义 json.hpp:1127
#define JSON_EXPLICIT
定义 json.hpp:2847
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
定义 json.hpp:1420
#define JSON_HEDLEY_PURE
定义 json.hpp:1811
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
定义 json.hpp:22906
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
定义 json.hpp:17423
cached_power get_cached_power_for_binary_exponent(int e)
定义 json.hpp:17259
Target reinterpret_bits(const Source source)
定义 json.hpp:16979
boundaries compute_boundaries(FloatType value)
定义 json.hpp:17120
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
定义 json.hpp:17477
constexpr int kAlpha
定义 json.hpp:17242
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
定义 json.hpp:17759
constexpr int kGamma
定义 json.hpp:17243
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
定义 json.hpp:17518
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
定义 json.hpp:17859
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
定义 json.hpp:17911
constexpr bool is_transparent()
定义 json.hpp:4218
constexpr bool is_c_string()
定义 json.hpp:4190
detail namespace with internal helper functions
定义 json.hpp:273
make_integer_sequence< size_t, N > make_index_sequence
定义 json.hpp:3215
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
定义 json.hpp:4293
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
定义 json.hpp:4100
input_format_t
the supported input formats
定义 json.hpp:6200
typename detector< nonesuch, void, Op, Args... >::type detected_t
定义 json.hpp:324
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
定义 json.hpp:5804
decltype(T::to_json(std::declval< Args >()...)) to_json_function
定义 json.hpp:3541
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
定义 json.hpp:9082
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
定义 json.hpp:4314
decltype(std::declval< T & >().end_object()) end_object_function_t
定义 json.hpp:9094
OutStringType concat(Args &&... args)
定义 json.hpp:4373
typename T::value_type value_type_t
定义 json.hpp:3526
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
定义 json.hpp:3246
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
定义 json.hpp:17996
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
定义 json.hpp:9062
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
定义 json.hpp:333
is_detected< string_can_append, StringType, Arg > detect_string_can_append
定义 json.hpp:4296
typename std::enable_if< B, T >::type enable_if_t
定义 json.hpp:3119
parse_event_t
定义 json.hpp:12227
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
定义 json.hpp:4096
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
定义 json.hpp:318
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
定义 json.hpp:4016
typename T::pointer pointer_t
定义 json.hpp:3532
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
定义 json.hpp:5034
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
定义 json.hpp:4845
typename utility_internal::Gen< T, N >::type make_integer_sequence
定义 json.hpp:3207
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
定义 json.hpp:14983
typename detected_or< Default, Op, Args... >::type detected_or_t
定义 json.hpp:330
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
定义 json.hpp:9090
decltype(std::declval< T & >().null()) null_function_t
定义 json.hpp:9059
T conditional_static_cast(U value)
定义 json.hpp:4074
typename T::difference_type difference_type_t
定义 json.hpp:3529
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
定义 json.hpp:9086
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_t
定义 json.hpp:9074
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
定义 json.hpp:2995
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
定义 json.hpp:9097
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
定义 json.hpp:4308
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
定义 json.hpp:5366
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
定义 json.hpp:4047
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
定义 json.hpp:3620
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
定义 json.hpp:4043
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
定义 json.hpp:6602
cbor_tag_handler_t
how to treat CBOR tags
定义 json.hpp:9209
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
定义 json.hpp:3771
make_index_sequence< sizeof...(Ts)> index_sequence_for
定义 json.hpp:3223
void concat_into(OutStringType &)
定义 json.hpp:4289
constexpr bool value_in_range_of(T val)
定义 json.hpp:4174
value_t
the JSON type enumeration
定义 json.hpp:2897
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
decltype(T::from_json(std::declval< Args >()...)) from_json_function
定义 json.hpp:3544
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
定义 json.hpp:4928
std::size_t hash(const BasicJsonType &j)
hash a JSON value
定义 json.hpp:6046
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
定义 json.hpp:9066
typename make_void< Ts... >::type void_t
定义 json.hpp:279
std::size_t combine(std::size_t seed, std::size_t h) noexcept
定义 json.hpp:6028
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
定义 json.hpp:9104
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
定义 json.hpp:2926
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
定义 json.hpp:6545
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
定义 json.hpp:3768
typename T::iterator_category iterator_category_t
定义 json.hpp:3538
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
定义 json.hpp:13815
error_handler_t
how to treat decoding errors
定义 json.hpp:18076
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
定义 json.hpp:4034
std::size_t concat_length()
定义 json.hpp:4258
std::integral_constant< bool, Value > bool_constant
定义 json.hpp:4180
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
定义 json.hpp:3105
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
定义 json.hpp:4688
typename T::key_compare detect_key_compare
定义 json.hpp:3604
void to_json(BasicJsonType &j, T b) noexcept
定义 json.hpp:5666
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
定义 json.hpp:4702
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
定义 json.hpp:336
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
定义 json.hpp:4305
decltype(std::declval< T & >().end_array()) end_array_function_t
定义 json.hpp:9101
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
定义 json.hpp:5028
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
定义 json.hpp:4311
typename T::key_type key_type_t
定义 json.hpp:3523
typename T::reference reference_t
定义 json.hpp:3535
typename T::is_transparent detect_is_transparent
定义 json.hpp:4010
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
定义 json.hpp:4302
typename T::mapped_type mapped_type_t
定义 json.hpp:3520
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
定义 json.hpp:4299
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
定义 json.hpp:3014
void int_to_string(string_type &target, std::size_t value)
定义 json.hpp:5203
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
定义 json.hpp:9078
decltype(std::declval< T >().template get< U >()) get_template_function
定义 json.hpp:3547
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
定义 json.hpp:9070
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
定义 json.hpp:12243
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
定义 json.hpp:24561
namespace for Niels Lohmann
定义 json.hpp:5857
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
定义 json.hpp:5881
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
定义 json.hpp:5871
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
定义 json.hpp:5861
typename BasicJsonType::object_t object_t
定义 json.hpp:3613
typename BasicJsonType::default_object_comparator_t object_comparator_t
定义 json.hpp:3614
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
定义 json.hpp:3615
signed char char_type
定义 json.hpp:3659
static constexpr int_type eof() noexcept
定义 json.hpp:3673
uint64_t int_type
定义 json.hpp:3660
static char_type to_char_type(int_type i) noexcept
定义 json.hpp:3668
static int_type to_int_type(char_type c) noexcept
定义 json.hpp:3663
static char_type to_char_type(int_type i) noexcept
定义 json.hpp:3644
static constexpr int_type eof() noexcept
定义 json.hpp:3649
unsigned char char_type
定义 json.hpp:3635
uint64_t int_type
定义 json.hpp:3636
static int_type to_int_type(char_type c) noexcept
定义 json.hpp:3639
std::true_type value_t
定义 json.hpp:313
Op< Args... > type
定义 json.hpp:314
std::false_type value_t
定义 json.hpp:306
Default type
定义 json.hpp:307
diyfp minus
定义 json.hpp:17109
diyfp plus
定义 json.hpp:17110
std::uint64_t f
定义 json.hpp:17247
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
定义 json.hpp:17013
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
定义 json.hpp:17095
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
定义 json.hpp:17078
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
定义 json.hpp:17001
constexpr diyfp(std::uint64_t f_, int e_) noexcept
定义 json.hpp:16995
static constexpr int kPrecision
定义 json.hpp:16990
std::uint64_t f
定义 json.hpp:16992
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
定义 json.hpp:5591
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
定义 json.hpp:5566
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
定义 json.hpp:5556
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
定义 json.hpp:5578
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
定义 json.hpp:5607
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
定义 json.hpp:5495
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
定义 json.hpp:5504
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
定义 json.hpp:5449
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
定义 json.hpp:5517
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
定义 json.hpp:5543
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
定义 json.hpp:5530
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
定义 json.hpp:5626
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
定义 json.hpp:5647
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
定义 json.hpp:5636
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
定义 json.hpp:5471
static void construct(BasicJsonType &j, const CompatibleStringType &str)
定义 json.hpp:5482
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
定义 json.hpp:5462
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
定义 json.hpp:5125
typename BasicJsonType::template json_serializer< T, void > serializer
定义 json.hpp:3566
typename BasicJsonType::template json_serializer< T, void > serializer
定义 json.hpp:3581
typename BasicJsonType::template json_serializer< T, void > serializer
定义 json.hpp:3596
T value_type
定义 json.hpp:3148
static constexpr std::size_t size() noexcept
定义 json.hpp:3149
an iterator value
定义 json.hpp:12873
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
定义 json.hpp:12877
primitive_iterator_t primitive_iterator
generic iterator for all other types
定义 json.hpp:12879
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
定义 json.hpp:12875
std::numeric_limits< RealIntegerType > RealLimits
定义 json.hpp:3942
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
定义 json.hpp:3943
typename BasicJsonType::object_t object_t
定义 json.hpp:3793
static constexpr auto value
定义 json.hpp:3843
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
定义 json.hpp:3914
typename BasicJsonType::object_t object_t
定义 json.hpp:3817
ConstructibleStringType laundered_type
定义 json.hpp:3854
static constexpr auto value
定义 json.hpp:3857
static constexpr bool value
定义 json.hpp:3560
typename std::iterator_traits< T >::value_type value_type
定义 json.hpp:6522
char x[2]
定义 json.hpp:4063
static one test(decltype(&C::capacity))
static constexpr bool value
定义 json.hpp:3764
static constexpr bool value
定义 json.hpp:9123
T value_type
定义 json.hpp:3328
T * pointer
定义 json.hpp:3330
ptrdiff_t difference_type
定义 json.hpp:3329
T & reference
定义 json.hpp:3331
std::random_access_iterator_tag iterator_category
定义 json.hpp:3327
typename It::iterator_category iterator_category
定义 json.hpp:3308
typename It::difference_type difference_type
定义 json.hpp:3304
typename It::value_type value_type
定义 json.hpp:3305
typename It::reference reference
定义 json.hpp:3307
typename It::pointer pointer
定义 json.hpp:3306
Default base class of the basic_json class.
定义 json.hpp:13812
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
定义 json.hpp:14969
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
定义 json.hpp:3060
std::size_t chars_read_current_line
the number of characters read in the current line
定义 json.hpp:3064
std::size_t lines_read
the number of lines read
定义 json.hpp:3066
std::size_t chars_read_total
the total number of characters read
定义 json.hpp:3062
static JSON_INLINE_VARIABLE constexpr T value
定义 json.hpp:3237
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
定义 json.hpp:5826
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
定义 json.hpp:3187
static constexpr bool test(T val)
定义 json.hpp:4158
static constexpr bool test(T)
定义 json.hpp:4167
static constexpr bool test(T val)
定义 json.hpp:4112
static constexpr bool test(T val)
定义 json.hpp:4132
static constexpr bool test(T val)
定义 json.hpp:4122
static constexpr bool test(T val)
定义 json.hpp:4142
SAX interface
定义 json.hpp:6694
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
定义 json.hpp:6695
typename BasicJsonType::string_t string_t
定义 json.hpp:6698
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
定义 json.hpp:6697
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
定义 json.hpp:6696
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
定义 json.hpp:6699
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
定义 json.hpp:19058
std::vector< std::pair< const Key, T >, Allocator > Container
定义 json.hpp:19061
std::pair< iterator, bool > insert(value_type &&value)
定义 json.hpp:19352
typename Container::value_type value_type
定义 json.hpp:19065
std::equal_to< Key > key_compare
定义 json.hpp:19069
iterator erase(iterator pos)
定义 json.hpp:19230
T mapped_type
定义 json.hpp:19060
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
定义 json.hpp:19075
T & operator[](KeyType &&key)
定义 json.hpp:19117
typename Container::iterator iterator
定义 json.hpp:19062
const T & at(KeyType &&key) const
定义 json.hpp:19177
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
定义 json.hpp:19371
T & at(KeyType &&key)
定义 json.hpp:19149
const T & operator[](KeyType &&key) const
定义 json.hpp:19129
iterator find(const key_type &key)
定义 json.hpp:19314
iterator erase(iterator first, iterator last)
定义 json.hpp:19235
const T & at(const key_type &key) const
定义 json.hpp:19162
const_iterator find(const key_type &key) const
定义 json.hpp:19340
T & operator[](const key_type &key)
定义 json.hpp:19110
size_type erase(KeyType &&key)
定义 json.hpp:19211
typename Container::size_type size_type
定义 json.hpp:19064
ordered_map() noexcept(noexcept(Container()))
定义 json.hpp:19074
void insert(InputIt first, InputIt last)
定义 json.hpp:19375
size_type count(const key_type &key) const
定义 json.hpp:19288
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
定义 json.hpp:19097
size_type erase(const key_type &key)
定义 json.hpp:19190
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
定义 json.hpp:19079
std::pair< iterator, bool > insert(const value_type &value)
定义 json.hpp:19357
size_type count(KeyType &&key) const
定义 json.hpp:19302
Key key_type
定义 json.hpp:19059
ordered_map(It first, It last, const Allocator &alloc=Allocator())
定义 json.hpp:19077
const T & operator[](const key_type &key) const
定义 json.hpp:19122
iterator find(KeyType &&key)
定义 json.hpp:19328
T & at(const key_type &key)
定义 json.hpp:19134
typename Container::const_iterator const_iterator
定义 json.hpp:19063
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
定义 json.hpp:19082
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
定义 json.hpp:24530
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
定义 json.hpp:24544